I've created @mixin in SASS to do media queries for me;
@mixin break($bp1, $minmax:minmax, $media:screen, $bp2:null){
@if $minmax == "minmax" and variable-exists(bp1) and $bp2{
@media #{$media} and (min-width: $bp1) and (max-width: #{$bp2 - 1px}){
@content;
}
} @else if $minmax == "min" and variable-exists(bp1){
@media #{$media} and (min-width: $bp1){
@content;
}
} @else if $minmax == "max" and variable-exists(bp1){
@media #{$media} and (max-width: #{$bp1 - 1}){
@content;
}
}
}
Works perfect, but I want to add another part (aspect-ratio, orientation etc.) to the @media query - string, just after the whole created Query. Ive tried hard, but it keeps telling: Unexpected token SASS_VAR found or something similar.
Code looks like:
@mixin break($bp1, $minmax:minmax, $media:screen, $after:null, $bp2:null){
@if $minmax == "minmax" and variable-exists(bp1) and $bp2{
@media #{$media} and (min-width: $bp1) and (max-width: #{$bp2 - 1px}) #{$after}{
@content;
}
} @else if $minmax == "min" and variable-exists(bp1){
@media #{$media} and (min-width: $bp1){
@content;
}
} @else if $minmax == "max" and variable-exists(bp1){
@media #{$media} and (max-width: #{$bp1 - 1}){
@content;
}
}
}
It's my first time with SASS. I've read about built-in CSS3 @mixins I'm used to PHP, where it's like
echo "@media ... and () .." . $after;
What should I do? Thanks :)
the new mixin looks good, but I want to have the last parameter optional, so I don't want hard-coded "and"