Skip to content

Instantly share code, notes, and snippets.

@adavize0
Created March 11, 2023 00:33
Show Gist options
  • Save adavize0/b18a6450d77920028b16a102713b6ff3 to your computer and use it in GitHub Desktop.
Save adavize0/b18a6450d77920028b16a102713b6ff3 to your computer and use it in GitHub Desktop.
Responsive SCSS breakpoints and media-query mixins
$breakpoints: (
xs: 320px,
sm: 576px,
md: 768px,
lg: 992px,
xl: 1200px,
xxl: 1440px
);
// Mixins for each breakpoint
@mixin xs {
$value: map-get($breakpoints, xs);
@media only screen and (min-width: #{$value}) {
@content;
}
}
@mixin xs-max {
$value: map-get($breakpoints, xs);
@media only screen and (max-width: #{$value}) {
@content;
}
}
@mixin sm {
$value: map-get($breakpoints, sm);
@media only screen and (min-width: #{$value}) {
@content;
}
}
@mixin sm-max {
$value: map-get($breakpoints, sm);
@media only screen and (max-width: #{$value}) {
@content;
}
}
@mixin md {
$value: map-get($breakpoints, md);
@media only screen and (min-width: #{$value}) {
@content;
}
}
@mixin md-max {
$value: map-get($breakpoints, md);
@media only screen and (max-width: #{$value}) {
@content;
}
}
@mixin lg {
$value: map-get($breakpoints, lg);
@media only screen and (min-width: #{$value}) {
@content;
}
}
@mixin lg-max {
$value: map-get($breakpoints, lg);
@media only screen and (max-width: #{$value}) {
@content;
}
}
@mixin xl {
$value: map-get($breakpoints, xl);
@media only screen and (min-width: #{$value}) {
@content;
}
}
@mixin xl-max {
$value: map-get($breakpoints, xl);
@media only screen and (max-width: #{$value}) {
@content;
}
}
@mixin xxl {
$value: map-get($breakpoints, xxl);
@media only screen and (min-width: #{$value}) {
@content;
}
}
@mixin xxl-max {
$value: map-get($breakpoints, xxl);
@media only screen and (max-width: #{$value}) {
@content;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment