Created
January 13, 2015 19:57
-
-
Save carlsverre/36e5d413f738de7bacfd to your computer and use it in GitHub Desktop.
Simple SCSS breakpoint implementation
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: ( | |
zero: 0px, | |
small: 900px, | |
medium: 1200px, | |
medium-large: 1400px, | |
large: 1600px, | |
xlarge: 2000px | |
); | |
@mixin breakpoint($left, $right: null) { | |
@if $right != null { | |
@media screen and (min-width: map-get($breakpoints, $left)) and (max-width: map-get($breakpoints, $right) - 1) { | |
@content; | |
} | |
} @else { | |
@media screen and (min-width: map-get($breakpoints, $left)) { | |
@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
.foo { | |
@include breakpoint(zero, small) { | |
width: 100px; | |
} | |
@include breakpoint(small, medium) { | |
width: 200px; | |
} | |
@include breakpoint(medium) { | |
width: 300px; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment