Skip to content

Instantly share code, notes, and snippets.

@Kcko
Created October 5, 2017 13:53
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 Kcko/3ffdf282c6f3673608e2bc4a4a2b3235 to your computer and use it in GitHub Desktop.
Save Kcko/3ffdf282c6f3673608e2bc4a4a2b3235 to your computer and use it in GitHub Desktop.
Bootstrap mixins
@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