Last active
August 29, 2015 14:24
-
-
Save egstad/bef373f82e0e18d8d77e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Viewport sizes | |
$vp1 : 40em; | |
$vp2 : 60em; | |
@mixin breakpoint($min:$vp1, $max:null) { | |
// for max-width | |
@if $min == max { | |
@media (max-width: $max) { @content; } | |
} | |
// min & max-width | |
@elseif ($min) and ($max) { | |
@media (min-width: $min) and (max-width: $max) { @content; } | |
} | |
// min-width (default) | |
@else { | |
@media (min-width: $min) { @content; } | |
} | |
} | |
/** | |
* Examples | |
*/ | |
// default (min-width at $vp1) | |
@include breakpoint() { | |
background: yellow; | |
} | |
// min-width at $vp2 | |
@include breakpoint($vp2) { | |
background: orange; | |
} | |
// min-width at $vp1, max-width at $vp2 | |
@include breakpoint($vp1, $vp2) { | |
background: red; | |
} | |
// max-width at $vp2 | |
@include breakpoint(max, $vp2) { | |
background: violet; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment