Created
January 5, 2016 10:16
-
-
Save andreasisaak/6433ec3dd531a36644b8 to your computer and use it in GitHub Desktop.
Mediaquery mixin
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
// Mediaquery mixin with mobile first approach | |
// | |
// $values - One or two numbers for the breakpoint | |
// $query - Use min(-width) or max(-width). Default: min. | |
// $expansion - Choose between width and height in the expansion? Default: width. | |
@mixin mq($values, $query: min, $expansion: width) { | |
@if length($values) > 1 { | |
$min: nth($values, 1); | |
$max: nth($values, 2); | |
@media only screen and (min-#{$expansion}: (strip-unit($min / $rem-base)) +em-calc(1)) and (max-#{$expansion}: (strip-unit($max / $rem-base)) +em) { | |
@content; | |
} | |
} @else if $values == 0 { | |
@media only screen { | |
@content; | |
} | |
} @else { | |
@if $query == min { | |
@media only screen and (#{$query}-#{$expansion}: (strip-unit($values / $rem-base)) +em-calc(1)) { | |
@content; | |
} | |
} @else { | |
@media only screen and (#{$query}-#{$expansion}: (strip-unit($values / $rem-base)) +em) { | |
@content; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment