Created
August 4, 2022 15:01
-
-
Save harrydayexe/fc003e6f3768b96b7b521b50a719bb18 to your computer and use it in GitHub Desktop.
Media Query Mixins for SASS
This file contains hidden or 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
// Media Query Mixins | |
$small-width: 576px; // Phone | |
$medium-width: 768px; // Tablet | |
$large-width: 1024px; // Desktop | |
// Media Breakpoint Up | |
// sm | md | lg | |
@mixin media-breakpoint-up($breakpoint) { | |
@if $breakpoint == sm { | |
@media (min-width: $small-width) { | |
@content; | |
} | |
} @else | |
if $breakpoint == md { | |
@media (min-width: $medium-width) { | |
@content; | |
} | |
} @else { | |
@media (min-width: $large-width) { | |
@content; | |
} | |
} | |
} | |
// Media Breakpoint Down | |
// sm | md | lg | |
@mixin media-breakpoint-down($breakpoint) { | |
@if $breakpoint == sm { | |
@media (max-width: $small-width) { | |
@content; | |
} | |
} @else | |
if $breakpoint == md { | |
@media (max-width: $medium-width) { | |
@content; | |
} | |
} @else { | |
@media (max-width: $large-width) { | |
@content; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment