Skip to content

Instantly share code, notes, and snippets.

@davidgilbertson
Last active September 16, 2020 11:08
Show Gist options
  • Save davidgilbertson/f40af111d843a1ccd8699ba3648f66d3 to your computer and use it in GitHub Desktop.
Save davidgilbertson/f40af111d843a1ccd8699ba3648f66d3 to your computer and use it in GitHub Desktop.
@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-landscape-up {
@media (min-width: $tablet-portrait-upper-boundary) { @content; }
} @else if $range == desktop-up {
@media (min-width: $tablet-landscape-upper-boundary) { @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