Skip to content

Instantly share code, notes, and snippets.

@JVMartin
Created September 3, 2014 02:36
Show Gist options
  • Save JVMartin/efe016744999df401284 to your computer and use it in GitHub Desktop.
Save JVMartin/efe016744999df401284 to your computer and use it in GitHub Desktop.
Media query mixins for BootStrap.
@mixin when($size) {
@if $size == 'xl' {
@media only screen and (min-width: 1200px) {
@content;
}
} @else if $size == 'l' {
@media only screen and (min-width: 992px) and (max-width: 1199px) {
@content;
}
} @else if $size == 'm' {
@media only screen and (min-width: 768px) and (max-width: 991px) {
@content;
}
} @else if $size == 's' {
@media only screen and (min-width: 480px) and (max-width: 767px) {
@content;
}
} @else if $size == 'xs' {
@media only screen and (min-width: 0px) and (max-width: 479px) {
@content;
}
}
}
@mixin and-below($size) {
@if $size == 'l' {
@media only screen and (max-width: 1199px) {
@content;
}
} @else if $size == 'm' {
@media only screen and (max-width: 991px) {
@content;
}
} @else if $size == 's' {
@media only screen and (max-width: 767px) {
@content;
}
} @else if $size == 'xs' {
@media only screen and (max-width: 479px) {
@content;
}
}
}
@mixin and-above($size) {
@if $size == 'l' {
@media only screen and (min-width: 992px) {
@content;
}
} @else if $size == 'm' {
@media only screen and (min-width: 768px) {
@content;
}
} @else if $size == 's' {
@media only screen and (min-width: 480px) {
@content;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment