Created
October 5, 2017 13:53
-
-
Save Kcko/3ffdf282c6f3673608e2bc4a4a2b3235 to your computer and use it in GitHub Desktop.
Bootstrap mixins
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
@mixin respond($minWidth: 0, $maxWidth: 0) { | |
@if $minWidth and $maxWidth | |
{ | |
@media screen and (min-width: $minWidth) and (max-width: $maxWidth) { @content; } | |
} | |
@else if $minWidth | |
{ | |
@media screen and (min-width: $minWidth) { @content; } | |
} | |
@else if $maxWidth | |
{ | |
@media screen and (max-width: $maxWidth) { @content; } | |
} | |
@else | |
{ | |
@warn "error - undefined params"; | |
} | |
} | |
@mixin breakpoint($class) | |
{ | |
@if $class == xs | |
{ | |
@media (max-width: 480px) { @content; } | |
} | |
@elseif $class == is | |
{ | |
@media (max-width: 767px) { @content; } | |
} | |
@else if $class == sm | |
{ | |
@media (max-width: 991px){ @content; } | |
} | |
@else if $class == md | |
{ | |
@media (max-width: 1199px) { @content; } | |
} | |
@else if $class == lg | |
{ | |
@media (min-width: 1200px) { @content; } | |
} | |
@else | |
{ | |
@warn "Breakpoint mixin supports: is, xs, sm, md, lg"; | |
} | |
} | |
#test | |
{ | |
@include breakpoint(lg) | |
{ | |
background: red; | |
} | |
@include breakpoint(md) | |
{ | |
background: green; | |
} | |
@include breakpoint(sm) | |
{ | |
background: purple; | |
} | |
@include breakpoint(xs) | |
{ | |
background: blue; | |
} | |
@include breakpoint(is) | |
{ | |
background: gold; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment