Skip to content

Instantly share code, notes, and snippets.

@kevin-ashton
Created February 25, 2014 18:06
Show Gist options
  • Save kevin-ashton/9214414 to your computer and use it in GitHub Desktop.
Save kevin-ashton/9214414 to your computer and use it in GitHub Desktop.
Media Query Scss Mixin
//Based off of http://css-tricks.com/media-queries-sass-3-2-and-codekit/
@mixin bp-min-width($point) {
@media (min-width: $point) { @content; }
}
@mixin bp-max-width($point) {
@media (max-width: $point) { @content; }
}
//Order matters for this plugin as it is currently written
@mixin bp($point) {
//Default sizes taken from Bootstrap 3
$screen-sm: 768px !default;
$screen-md: 992px !default;
@if $point == desktop {
@include bp-min-width($screen-md + 1) {@content}
// @media (min-width: ($screen-md + 1)) { @content; }
}
@else if $point == tablet {
@include bp-max-width($screen-md) {@content}
// @media (max-width: $screen-md) { @content; }
}
@else if $point == phone {
@include bp-max-width($screen-sm) {@content}
// @media (max-width: $screen-sm) { @content; }
}
}
//Curent implementation requies that you do the desktop first
body{
@include bp(desktop){background-color: lightpink;}
@include bp(tablet){background-color: lightgreen ;}
@include bp(phone){background-color: lightblue;}
}
@kevin-ashton
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment