Created
May 13, 2015 16:02
-
-
Save adamjohnson/510a9d3729c3247dcb4a to your computer and use it in GitHub Desktop.
Stu Robertson's Media Query Mixin Example
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
| // ---- | |
| // Sass (v3.4.13) | |
| // Compass (v1.0.3) | |
| // ---- | |
| $doc-font-size: 16; | |
| @mixin mq($point, $IE9: false, $query1: min, $query2: width) { | |
| @if $IE9 == true{ | |
| .lt-ie9 & { | |
| @content; | |
| } | |
| } | |
| @media (#{$query1}-#{$query2}: $point / $doc-font-size +em) { | |
| @content; | |
| } | |
| } | |
| // Simple Example | |
| .example { | |
| width: 200px; | |
| @include mq(500) { width: 500px; } | |
| } | |
| // Or, even better with variables for breakpoints: | |
| $bp-small: 300; | |
| .with-variables { | |
| width: 300px; | |
| @include mq($bp-small) { width: 400px; } | |
| } |
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
| .example { | |
| width: 200px; | |
| } | |
| @media (min-width: 31.25em) { | |
| .example { | |
| width: 500px; | |
| } | |
| } | |
| .with-variables { | |
| width: 300px; | |
| } | |
| @media (min-width: 18.75em) { | |
| .with-variables { | |
| width: 400px; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment