Last active
June 2, 2016 13:17
-
-
Save davidjpfeiffer/611fb96e0fb49645336a0d61c7ddb0c5 to your computer and use it in GitHub Desktop.
SASS mixin to generate breakpoints for a given style
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
// Breakpoint Variables | |
$xs-break: em(400px); | |
$sm-break: em(600px); | |
$md-break: em(800px); | |
$lg-break: em(1000px); | |
$xl-break: em(1200px); | |
// Size Suffixes | |
$xs-suffix: "-xs"; | |
$sm-suffix: "-sm"; | |
$md-suffix: "-md"; | |
$lg-suffix: "-lg"; | |
$xl-suffix: "-xl"; | |
$breakpoint-map: ( | |
$xs-suffix: $xs-break, | |
$sm-suffix: $sm-break, | |
$md-suffix: $md-break, | |
$lg-suffix: $lg-break, | |
$xl-suffix: $xl-break | |
); | |
@mixin breakpoint($suffix, $break) { | |
@media (min-width: $break) { | |
&#{$suffix} { @content; } | |
} | |
} | |
@mixin breakpoints { | |
@each $suffix, $break in $breakpoint-map { | |
@include breakpoint($suffix, $break) { @content; } | |
} | |
} | |
.hide { | |
@include breakpoints { | |
display: none; | |
} | |
} | |
.show { | |
@include breakpoints { | |
display: block; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment