Last active
December 30, 2015 11:29
-
-
Save b44rd/7822440 to your computer and use it in GitHub Desktop.
A responsive elementquery mixin for scss. Uses http://marcj.github.io/css-element-queries/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The mixin | |
@mixin elementquery ($elementsize) { | |
@if $elementsize == small { | |
&[max-width="200px"]{ @content; } | |
} | |
@else if $elementsize == medium { | |
&[max-width="500px"]{ @content; } | |
} | |
@else if $elementsize == large { | |
&[max-width="800px"]{ @content; } | |
} | |
@else if $elementsize == full { | |
&[max-width="1200px"]{ @content; } | |
} | |
@else { | |
&[max-width="#{$elementsize}"]{ @content; } | |
} | |
} | |
// Usage | |
.test { | |
background: #ff0; | |
@include elementquery(340px){ | |
background: #fc6; | |
}; | |
@include elementquery(large){ | |
background: #f00; | |
}; | |
} | |
// Compiled result | |
.test { background: #ff0; } | |
.test[max-width="340px"] { background: #fc6; } | |
.test[max-width="800px"] { background: #f00; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment