I have this mediaquery on my iframe:
@include breakpoint(m)
that will be called in:
@mixin breakpoint($class) {
@if $class == s {
@media (max-width: 599px) { @content; }
}
@else if $class == m {
@media (min-width: 768px) { @content; }
}
@else if $class == l {
@media (min-width: 1280px) { @content; }
}
}
however, when passing m doesn’t work and it will only trigger on l (1280px). if I pass l, nothing happens. why?
i tried to add "screen and" but didn’t work!
2
Answers
apparently it worked with the deprecated
min-device-width
the problem was in the iframe itself and not in SCSS.
Unfortunately, I’m not well-versed in Sass mq’s using breakpoints and mixins together enough to tell you why yours isn’t working, but I think I can build you a version that does work. what’s not working could be a few things: I’m honestly not sure if you can have one-character mixins, but I could be pulling that out of my rear-end. I think your main problem may be that the s, m, and l variables aren’t declared before your mixins, but I could also be wrong there.
Instead of trying to declare everything in one mixin using breakpoint, it might be easier to use multiple variables:
then we can declare the mixins:
If you do want to use breakpoint, you need to declare your variable:
then you can either use those directly in mq’s:
Or you can go one further like you’re doing above and implement those breakpoints into a mixin… and tbh i never go this far. I always just use breakpoints. Everything I’m about to write is entirely based off of this: https://glennmccomb.com/articles/useful-sass-scss-media-query-mixins-for-bootstrap/
Like I said, all of that is copied from the URL above.
I hope it’s helpful. Comment back and tell me if any particular area is tripping you up and i’ll see if I can do a better job explaining it.