Skip to content

Instantly share code, notes, and snippets.

@cimmanon
Created December 16, 2015 13:51
Show Gist options
  • Save cimmanon/52cd587b351f13c35e81 to your computer and use it in GitHub Desktop.
Save cimmanon/52cd587b351f13c35e81 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.20)
// Compass (v1.0.3)
// ----
@mixin media($query: $feature $value $columns, $total-columns: $grid- columns) {
@if length($query) == 1 {
@media screen and ($default-feature: nth($query, 1)) {
$default-grid-columns: $grid-columns;
$grid-columns: $total-columns !global;
@content;
$grid-columns: $default-grid-columns !global;
}
} @else {
$loop-to: length($query);
$media-query: "screen and ";
$default-grid-columns: $grid-columns;
$grid-columns: $total-columns !global;
@if is-not(is-even(length($query))) {
$grid-columns: nth($query, $loop-to) !global;
$loop-to: $loop-to - 1;
}
$i: 1;
@while $i <= $loop-to {
$media-query: $media-query + "(" + nth($query, $i) + ": " + nth($query, $i + 1) + ") ";
@if ($i + 1) != $loop-to {
$media-query: $media-query + "and ";
}
$i: $i + 2;
}
@media #{$media-query} {
@content;
$grid-columns: $default-grid-columns !global;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment