Skip to content

Instantly share code, notes, and snippets.

@axxe16
Last active January 31, 2020 13:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axxe16/a3288c49b9f35716a23743e1131dd514 to your computer and use it in GitHub Desktop.
Save axxe16/a3288c49b9f35716a23743e1131dd514 to your computer and use it in GitHub Desktop.
respond under above media query scss #scss #css #mediaQuery #responsive
// 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