Skip to content

Instantly share code, notes, and snippets.

@Phunky
Created April 9, 2014 09:01
Show Gist options
  • Save Phunky/10244379 to your computer and use it in GitHub Desktop.
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.
@import "breakpoint";
body {
@include breakpoint(large){
background: red;
}
@include breakpoint(normal){
background: green;
}
@include breakpoint(small){
background: blue;
}
}
$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;
}
}
}
@import "base";
$breakpoints-to-output: (
large: true,
normal: ture,
small: ture,
);
@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