Last active
August 29, 2019 06:37
-
-
Save nmsdvid/26737c57d8d353689509ceaaf205e63b to your computer and use it in GitHub Desktop.
SASS breakpoint mixin
This file contains hidden or 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
// https://rimdev.io/making-media-query-mixins-with-sass/ | |
// example | |
.class { | |
@include breakpoint(1200px, max) { | |
display: block; | |
} | |
} | |
.class { | |
@include breakpoint(500px, min) { | |
@include breakpoint(1000px, max) { | |
display: none; | |
} | |
} | |
} | |
// Media query mixin | |
@mixin breakpoint($breakpoint, $direction) { | |
@if $direction == max { | |
@media (max-width: $breakpoint) { | |
@content; | |
} | |
} @else if $direction == min { | |
@media (min-width: $breakpoint) { | |
@content; | |
} | |
} @else { | |
@media ($direction: $breakpoint) { | |
@content | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment