New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set variables using media query #1227
Comments
While this would be pretty cool, it's very much contrary to the existing semantics of a Sass stylesheet. What you've outlined already has a meaning: it sets the variable twice in sequence and then accesses it (modulo some scoping issues). The sequential and largely imperative nature of Sass means that the sort of automatic duplication of rules you're describing becomes very complex. We actually considered something very similar for handling SassScript The best approximation you can do right now is to put the styles that need to vary in a mixin with parameters and include that in your media queries. |
@nex3 For example: $container-width: 980;
$right-column-width: 200;
div#contentwrapper {
width: $container-width + px;
div.left {
width: $container-width - $right-column-width + px;
}
@media (max-width: 300px) {
$container-width: 1140;
} At compiling sass detects where the variable $container-width is used and compiles to: div#contentwrapper {
width: 980px;
}
div#contentwrapper div.left {
width: 780px;
}
@media (max-width: 300px) {
div#contentwrapper {
width: 1140px;
}
div#contentwrapper div.left {
width: 940px;
}
} |
+1 for this |
1 similar comment
+1 for this |
+1 for this |
I would like to be able to set variables using media queries. This would mean that with the following input:
I would expect the following output:
This would provide a convenient way of setting variables based on screen width without largely repeating ourselves with the rest of the CSS code that must be written.
The text was updated successfully, but these errors were encountered: