Last active
January 31, 2020 13:47
-
-
Save axxe16/a3288c49b9f35716a23743e1131dd514 to your computer and use it in GitHub Desktop.
respond under above media query scss #scss #css #mediaQuery #responsive
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
// A map of breakpoints. | |
$breakpoints: (xs: 576px, | |
sm: 768px, | |
md: 992px, | |
lg: 1200px); | |
// Respond above. | |
@mixin respond-above($breakpoint) { | |
// If the breakpoint exists in the map. | |
@if map-has-key($breakpoints, $breakpoint) { | |
// Get the breakpoint value. | |
$breakpoint-value: map-get($breakpoints, $breakpoint); | |
// Write the media query. | |
@media (min-width: $breakpoint-value) { | |
@content; | |
} | |
// If the breakpoint doesn't exist in the map. | |
} | |
@else { | |
// Log a warning. | |
@warn 'Invalid breakpoint: #{$breakpoint}.'; | |
} | |
} | |
// Respond above. | |
@mixin respond-under($breakpoint) { | |
// If the breakpoint exists in the map. | |
@if map-has-key($breakpoints, $breakpoint) { | |
// Get the breakpoint value. | |
$breakpoint-value: map-get($breakpoints, $breakpoint); | |
// Write the media query. | |
@media (max-width: $breakpoint-value) { | |
@content; | |
} | |
// If the breakpoint doesn't exist in the map. | |
} | |
@else { | |
// Log a warning. | |
@warn 'Invalid breakpoint: #{$breakpoint}.'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment