Created
April 9, 2014 09:01
-
-
Save Phunky/10244379 to your computer and use it in GitHub Desktop.
This is an example of how I use SCSS to output separate stylesheets for each breakpoint while only maintaining it in one place, i've also go another version of the mixing which uses the same concept without breakpoints. At some point i'd like to combine these into a single mixin.
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
@import "breakpoint"; | |
body { | |
@include breakpoint(large){ | |
background: red; | |
} | |
@include breakpoint(normal){ | |
background: green; | |
} | |
@include breakpoint(small){ | |
background: blue; | |
} | |
} |
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
$breakpoints: ( | |
large: 'screen and (min-width: 1200px)', | |
normal: 'screen and (min-width: 960px) and (max-width: 1200px)', | |
normal-up: 'screen and (min-width: 960px)', | |
small: 'screen and (max-width: 960px)', | |
); | |
@mixin breakpoint($key){ | |
@if map-has-key($breakpoints-to-output, $key) { | |
@media #{map-get($breakpoints, $key)} { | |
@content; | |
} | |
} | |
} |
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
@import "base"; | |
$breakpoints-to-output: ( | |
large: true, | |
normal: ture, | |
small: ture, | |
); |
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
@import "base"; | |
$breakpoints-to-output: ( | |
small: ture, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment