Created
September 16, 2018 04:26
-
-
Save eldyvoon/87213c12a788feb8a3484ebf03311418 to your computer and use it in GitHub Desktop.
media query mixin scss/sass to avoid duplication
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
// variables.scss file | |
$breakpoints:( | |
sm: 640px, | |
md: 1200px, | |
lg: 1400px, | |
xl: 1900px | |
); | |
// mixins.scss file | |
@mixin min-width($breakpoint){ | |
@media only screen and (min-width:#{map-get($breakpoints, $breakpoint)}) { | |
@content; | |
} | |
} | |
// module.scss file | |
.innerWrap { | |
display: flex; | |
align-items: center; | |
&:first-child { | |
margin-right: 20px; | |
@include min-width(sm){ | |
margin-right: 0; | |
} | |
} | |
@include min-width(sm){ | |
flex: 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment