Last active
June 23, 2016 09:50
-
-
Save tankbar/1dd56b425faeef02e580bfeb248a6516 to your computer and use it in GitHub Desktop.
Media Queries helper in your SCSS project
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
// These mixins make media queries a breeze with SCSS. | |
// The media queries from mobile up until desktop all trigger at different points along the way. | |
// This helper is focused on mobile first. You style your block as it whould appear in mobile and then add CSS for how it scales up. | |
// | |
// Example | |
// .block { | |
// height: 250px; | |
// | |
// @include MQ(M) { | |
// height: 300px; | |
// } | |
// | |
// @include MQ(L) { | |
// height: 320px; | |
// } | |
// | |
// @include MQ(XL) { | |
// height: 350px; | |
// } | |
// | |
// @include MQ(XXL) { | |
// height: 400px; | |
// } | |
// } | |
// Breakpoints | |
// Change to your prefered breakpoints | |
$S: 480px; | |
$M: 768px; | |
$L: 1170px; | |
$XL: 1400px; | |
$XXL: 1600px; | |
// Media queries | |
@mixin MQ($canvas) { | |
@if $canvas == S { | |
@media only screen and (min-width: $S) { @content; } | |
} | |
@else if $canvas == M { | |
@media only screen and (min-width: $M) { @content; } | |
} | |
@else if $canvas == L { | |
@media only screen and (min-width: $L) { @content; } | |
} | |
@else if $canvas == XL { | |
@media only screen and (min-width: $XL) { @content; } | |
} | |
@else if $canvas == XXL { | |
@media only screen and (min-width: $XXL) { @content; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment