Skip to content

Instantly share code, notes, and snippets.

@ashblue
Created August 20, 2013 21:08
Show Gist options
  • Save ashblue/6287370 to your computer and use it in GitHub Desktop.
Save ashblue/6287370 to your computer and use it in GitHub Desktop.
SASS Media Queries done right
/**
Targets small screen sizes and below, hides CSS from all other sizes
@example
@include screen-small {
#main {
width: auto;
background: #000;
}
}
*/
@mixin screen-small {
@media screen and (max-width: $max-width) {
@content;
}
}
/**
Custom screen size for small media queries
@example
@include screen-small(300px) {
#main {
width: auto;
background: #000;
}
}
*/
@mixin screen-small-custom($size) {
@media screen and (max-width: $size) {
@content;
}
}
// Targets large screens
// @see screen-small
@mixin screen-large {
@media screen and (min-width: $min-width) {
@content;
}
}
// Custom large screen sizes
// @see screen-small
@mixin screen-large-custom($size) {
@media screen and (min-width: $size) {
@content;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment