Created
April 25, 2012 15:41
-
-
Save Snugug/2490750 to your computer and use it in GitHub Desktop.
Media Query Sass Mixin
This file contains hidden or 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
////////////////////////////// | |
// Generalized Media Query Mixin | |
// | |
// Requires Sass 3.2+ | |
// Until released: | |
// (sudo) gem install sass --pre | |
////////////////////////////// | |
@mixin media-query($value, $operator: 'min-width', $query: 'screen') { | |
@media #{$query} and (#{$operator}: #{$value}) { | |
@content; | |
} | |
} | |
////////////////////////////// | |
// Usage | |
////////////////////////////// | |
#foo { | |
background-color: red; | |
@include media-query(500px) { | |
background-color: green; | |
} | |
} | |
////////////////////////////// | |
// Output | |
////////////////////////////// | |
#foo { | |
background-color: red; | |
} | |
@media screen and (min-width: 500px) { | |
#foo { | |
background-color: green; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As per Scott Kellum's suggestion, made the 'min-width' operator a default.