Skip to content

Instantly share code, notes, and snippets.

@johnferrie
Forked from Snugug/media-query-mixin.scss
Created October 4, 2012 21:05
Show Gist options
  • Save johnferrie/3836460 to your computer and use it in GitHub Desktop.
Save johnferrie/3836460 to your computer and use it in GitHub Desktop.
Media Query Sass Mixin
//////////////////////////////
// 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