Created
December 26, 2014 15:09
-
-
Save eduardoboucas/7e7e2f783f4f737422b7 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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
// ---- | |
// Sass (v3.4.9) | |
// Compass (v1.0.1) | |
// ---- | |
/** | |
* Conditional Media Query Mixin | |
* by @sheiko (http://dsheiko.com) | |
* | |
* The problem this mixin solves is explained there | |
* http://css-tricks.com/conditional-media-query-mixins/ | |
* | |
* https://github.com/dsheiko | |
* MIT license: http://www.opensource.org/licenses/mit-license.php | |
*/ | |
// Predefined Break-points | |
$mediaMaxWidth: 1260px; | |
$mediaBp1Width: 960px; | |
$mediaMinWidth: 480px; | |
@function translate-media-condition($c) { | |
$condMap: ( | |
"screen": "only screen", | |
"print": "only print", | |
"retina": "(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-device-pixel-ratio: 1.5), (min-resolution: 120dpi)", | |
">maxWidth": "(min-width: #{$mediaMaxWidth + 1})", | |
"<maxWidth": "(max-width: #{$mediaMaxWidth})", | |
">bp1Width": "(min-width: #{$mediaBp1Width + 1})", | |
"<bp1Width": "(max-width: #{$mediaBp1Width})", | |
">minWidth": "(min-width: #{$mediaMinWidth + 1})", | |
"<minWidth": "(max-width: #{$mediaMinWidth})" | |
); | |
@return map-get( $condMap, $c ); | |
} | |
// The mdia mixin | |
@mixin media($args...) { | |
$query: ""; | |
@each $arg in $args { | |
$op: ""; | |
@if ( $query != "" ) { | |
$op: " and "; | |
} | |
$query: $query + $op + translate-media-condition($arg); | |
} | |
@media #{$query} { @content; } | |
} | |
/** | |
* Usage examples | |
*/ | |
.section { | |
@include media( "retina", "<minWidth" ){ | |
background: blue; | |
color: white; | |
}; | |
} | |
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
/** | |
* Conditional Media Query Mixin | |
* by @sheiko (http://dsheiko.com) | |
* | |
* The problem this mixin solves is explained there | |
* http://css-tricks.com/conditional-media-query-mixins/ | |
* | |
* https://github.com/dsheiko | |
* MIT license: http://www.opensource.org/licenses/mit-license.php | |
*/ | |
/** | |
* Usage examples | |
*/ | |
@media (-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3 / 2), (min-device-pixel-ratio: 1.5), (min-resolution: 120dpi) and (max-width: 480px) { | |
.section { | |
background: blue; | |
color: white; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment