Skip to content

Instantly share code, notes, and snippets.

@Ampa1R
Last active July 15, 2019 09:46
Show Gist options
  • Select an option

  • Save Ampa1R/c1097a642b8eacfc35887b8d6617cec2 to your computer and use it in GitHub Desktop.

Select an option

Save Ampa1R/c1097a642b8eacfc35887b8d6617cec2 to your computer and use it in GitHub Desktop.
SCSS respond-to mixin
@mixin respond-to($breakpoint) {
$raw-query: map-get($breakpoints, $breakpoint);
@if $raw-query {
$query: if(
type-of($raw-query) == 'string',
unquote($raw-query),
inspect($raw-query)
);
@media #{$query} {
@content;
}
} @else {
@media (max-width: $breakpoint) {
@content;
}
}
}
/*
.foo {
@include respond-to(1255px) {
background: gray;
}
@include respond-to(xs) {
background: white;
}
}
*/
$breakpoints: (
'xxs': (max-width: 375px),
'xs': (max-width: 425px),
'sm': (max-width: 576px),
'md': (max-width: 768px),
'lg': (max-width: 992px),
'xl': (max-width: 1200px),
'xxl': (max-width: 1400px),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment