Skip to content

Instantly share code, notes, and snippets.

@eduardoboucas
Created December 26, 2014 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduardoboucas/7e7e2f783f4f737422b7 to your computer and use it in GitHub Desktop.
Save eduardoboucas/7e7e2f783f4f737422b7 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// 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;
};
}
/**
* 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