Last active
February 2, 2024 07:36
-
-
Save davidtranjs/52a7309ddd2ed95b7461fb704d5c02cb to your computer and use it in GitHub Desktop.
SCSS mixin for media query 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
$screen-xs-max: 599px; | |
$screen-sm-min: 600px; | |
$screen-md-min: 960px; | |
$screen-lg-min: 1280px; | |
$screen-xl-min: 1920px; | |
@mixin xs { | |
@media screen and (max-width: #{$screen-xs-max}) { | |
@content; | |
} | |
} | |
@mixin sm { | |
@media screen and (min-width: #{$screen-sm-min}) { | |
@content; | |
} | |
} | |
@mixin md { | |
@media screen and (min-width: #{$screen-md-min}) { | |
@content; | |
} | |
} | |
@mixin lg { | |
@media screen and (min-width: #{$screen-lg-min}) { | |
@content; | |
} | |
} | |
@mixin xl { | |
@media screen and (min-width: #{$screen-xl-min}) { | |
@content; | |
} | |
} | |
// Usage example | |
// pageAbc.scss | |
@import './mixin-media-query.scss'; | |
.content { | |
color: red; | |
@include sm { | |
color: blue; | |
} | |
@include md { | |
color: yellow; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment