Last active
November 27, 2016 15:28
-
-
Save palicko/b0fe867e2b2d5b20007837e4dd4a5b24 to your computer and use it in GitHub Desktop.
Media queries mixin
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
@mixin for-size($range) { | |
$phone-upper-boundary: 600px; | |
$tablet-portrait-upper-boundary: 900px; | |
$tablet-landscape-upper-boundary: 1200px; | |
$desktop-upper-boundary: 1800px; | |
@if $range == phone-only { | |
@media (max-width: #{$phone-upper-boundary - 1}) { @content; } | |
} @else if $range == tablet-portrait-up { | |
@media (min-width: $phone-upper-boundary) { @content; } | |
} @else if $range == tablet-portait-only { | |
@media (min-width: $phone-upper-boundary) and (max-width: #{$tablet-portrait-upper-boundary - 1}) { @content; } | |
} @else if $range == tablet-landscape-up { | |
@media (min-width: $tablet-landscape-upper-boundary) { @content; } | |
} @else if $range == tablet-landscape-only { | |
@media (min-width: $tablet-portrait-upper-boundary) and (max-width: $tablet-landscape-upper-boundary - 1px) { @content; } | |
} @else if $range == desktop-up { | |
@media (min-width: $tablet-landscape-upper-boundary) { @content; } | |
} @else if $range == desktop-only { | |
@media (min-width: $tablet-landscape-upper-boundary) and (max-width: $desktop-upper-boundary - 1px) { @content; } | |
} @else if $range == big-desktop-up { | |
@media (min-width: $desktop-upper-boundary) { @content; } | |
} | |
} | |
// usage | |
.my-box { | |
padding: 10px; | |
@include for-size(desktop-up) { | |
padding: 20px; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment