Last active
October 22, 2015 21:02
-
-
Save jshakes/41a28f8443b2cd61565c to your computer and use it in GitHub Desktop.
Media queries and nesting
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
// BAD - lots of selector repetition and if we don't match the nesting/specificity in the media query, the rules we write may not override the defaults | |
.my-module { | |
height: 4em; | |
.my-module-header { | |
width: 100%; | |
.my-module-title { | |
font-size: 1em; | |
} | |
} | |
@include larger-than(mobile) { | |
height: 2em; | |
.my-module-header { | |
width: 50%; | |
} | |
.my-module-title { | |
font-size: 2em; | |
} | |
} | |
} | |
// GOOD - no repetition of selectors, no chance of media queries not overriding defaults, only have to think about nesting once | |
.my-module { | |
height: 4em; | |
@include larger-than(mobile) { | |
height: 2em; | |
} | |
.my-module-header { | |
width: 100%; | |
@include larger-than(mobile) { | |
width: 50%; | |
} | |
.my-module-title { | |
font-size: 1em; | |
@include larger-than(mobile) { | |
font-size: 2em; | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment