Last active
December 13, 2015 22:59
-
-
Save joshmatz/4988267 to your computer and use it in GitHub Desktop.
SCSS Mixin for creating media queries when needed. Supports lists as a parameter for use with multiple media queries.
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
/** | |
* Supports lists as a parameter for use when you want to select multiple media queries. | |
* @include respond-to(palm, phablet, lap) { .sub-nav { display: none; }} | |
*/ | |
@mixin respond-to($media...) { | |
$response-count: 0; | |
$query: ''; | |
@each $medium in $media { | |
@if $response-count > 0 { | |
$query: $query + ', '; | |
} | |
@if $medium == 'palm' { | |
$query: $query + '(max-width: 525px)'; | |
} | |
@if $medium == 'phablet' { | |
$query: $query + '(min-width: 526px) and (max-width: 759px)'; | |
} | |
@if $medium == 'lap' { | |
$query: $query + '(min-width: 760px) and (max-width: 990px)'; | |
} | |
@if $medium == 'desk' { | |
$query: $query + '(min-width: 991px) and (max-width: 1247px)'; | |
} | |
@if $medium == 'wide' { | |
$query: $query + '(min-width: 1248px)'; | |
} | |
@if $medium == 'height' { | |
$query: $query + '(min-height: 576px)'; | |
} | |
$response-count: $response-count + 1; | |
} | |
@media only screen and #{$query} { | |
@content; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment