Skip to content

Instantly share code, notes, and snippets.

@nandomoreirame
Last active November 6, 2017 12:46
Show Gist options
  • Save nandomoreirame/7c6c82078f13821cfefc0c718de807f6 to your computer and use it in GitHub Desktop.
Save nandomoreirame/7c6c82078f13821cfefc0c718de807f6 to your computer and use it in GitHub Desktop.
$default-feature: min-width
=media($query: $feature $value)
@if length($query) == 1
@media screen and ($default-feature: nth($query, 1))
@content
@else
$loop-to: length($query)
$media-query: "screen and "
@if length($query) % 2 != 0
$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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment