Skip to content

Instantly share code, notes, and snippets.

@nmsdvid
Last active August 29, 2019 06:37
Show Gist options
  • Save nmsdvid/26737c57d8d353689509ceaaf205e63b to your computer and use it in GitHub Desktop.
Save nmsdvid/26737c57d8d353689509ceaaf205e63b to your computer and use it in GitHub Desktop.
SASS breakpoint mixin
// 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