Design comparison
Solution retrospective
Is there something wrong with this mixin:
@mixin responsive($property, $size) {
@media ($property: $size) {
@content
}
}
It worked as expected, but VsCode refuses to put the variable color on the $property in the second line, and github also let it unpainted.
Community feedback
- @ah-nafPosted over 3 years ago
Try this.
@mixin responsive($property, $size) { @media (#{$property}: $size) { @content } }
You can also check the documentation for more.
Marked as helpful1@Paulo-EmerencioPosted over 3 years ago@ah-naf Thank you very much!
The poor var is still unpainted, but according to documentation this is the correct syntax, although the mixin also worked without the interpolation #{ }
0 - @xphstosPosted over 3 years ago
My question for that mixin would be why? Why write all that when you can simple nest the query on any rule you like?
@media (max-width: 1024px) { ... }
If you want to be faster just write a shortcut for this on your code editor, there is no need for a mixin like that. :)
Marked as helpful0@Paulo-EmerencioPosted over 3 years ago@xphstos
You're right, I feel stupid. Thanks for opening my eyes!
1
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord