Skip to content

Instantly share code, notes, and snippets.

@aaroniker
Created February 15, 2019 09:16
Show Gist options
  • Save aaroniker/421edafbdb19d7ab00d8850da3158381 to your computer and use it in GitHub Desktop.
Save aaroniker/421edafbdb19d7ab00d8850da3158381 to your computer and use it in GitHub Desktop.
$breakpoints: (
xs: 576px,
sm: 768px,
md: 992px,
lg: 1200px
);
@mixin min($breakpoint) {
@if map-has-key($breakpoints, $breakpoint) {
@media (min-width: map-get($breakpoints, $breakpoint)) {
@content;
}
} @else {
@media(min-width: $breakpoint) {
@content;
}
}
}
@mixin max($breakpoint) {
@if map-has-key($breakpoints, $breakpoint) {
@media(max-width: map-get($breakpoints, $breakpoint) - 1) {
@content;
}
} @else {
@media(max-width: $breakpoint) {
@content;
}
}
}
//Usage
@include min(xs|sm|md|lg|Xpx) { //CSS }
@include max(xs|sm|md|lg|Xpx) { //CSS }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment