Skip to content

Instantly share code, notes, and snippets.

@eldyvoon
Created September 16, 2018 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eldyvoon/87213c12a788feb8a3484ebf03311418 to your computer and use it in GitHub Desktop.
Save eldyvoon/87213c12a788feb8a3484ebf03311418 to your computer and use it in GitHub Desktop.
media query mixin scss/sass to avoid duplication
// 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