Created
February 25, 2014 18:06
-
-
Save kevin-ashton/9214414 to your computer and use it in GitHub Desktop.
Media Query Scss Mixin
This file contains hidden or 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
//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;} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For example see:
http://codepen.io/aashtonk/pen/gjDoH