Last active
December 18, 2015 02:29
-
-
Save stowball/5711299 to your computer and use it in GitHub Desktop.
Suzi's Media Query mixins
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
| @mixin media-query($value, $ltie9: true, $operator: $min, $px: false) { | |
| @if ($operator == $max and $value < $site-width) { | |
| // Do nothing | |
| } | |
| @else { | |
| @if ($ltie9 == true) { | |
| .ltie9 & { | |
| @content; | |
| } | |
| } | |
| } | |
| @if ($px == false) { | |
| @media (#{$operator} #{em($value)}) { | |
| @content; | |
| } | |
| } | |
| @else { | |
| @media (#{$operator} #{strip-units($value)}px) { | |
| @content; | |
| } | |
| } | |
| } | |
| @mixin media-query-and($first-value, $second-value, $ltie9: true, $first-operator: $min, $second-operator: $max, $px: false) { | |
| @if ($ltie9 == true and ($second-value >= $site-width)) { | |
| .ltie9 & { | |
| @content; | |
| } | |
| } | |
| @if ($px == false) { | |
| @media (#{$first-operator} #{em($first-value)}) and (#{$second-operator} #{em($second-value)}) { | |
| @content; | |
| } | |
| } | |
| @else { | |
| @media (#{$first-operator} #{strip-units($first-value)}) and (#{$second-operator} #{strip-units($second-value)}) { | |
| @content; | |
| } | |
| } | |
| } | |
| @mixin media-query-retina { | |
| @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi), (min-resolution: 2dppx) { | |
| @content; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a simplified (!) version of what I'm using. Note that two separate css files are output, each of them without duplicate rules. Also means you can use
+respond-to(obsolete)to quarantine IE hacks to the oldIE css file.