Last active
August 29, 2015 14:05
-
-
Save jonathanbiddle/3ca0a384d255af978908 to your computer and use it in GitHub Desktop.
Media Query mixins for Less
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
| /** | |
| * Requires >= Less 1.7 | |
| * | |
| * Usage: | |
| * | |
| * .column { | |
| * width: 1000px; | |
| * margin: 0 auto; | |
| * | |
| * .break-large(max, { | |
| * width: 100%; | |
| * margin: 0; | |
| * }); | |
| * } | |
| * | |
| * Compiles To: | |
| * | |
| * .column { | |
| * width: 1000px; | |
| * margin: 0 auto; | |
| * } | |
| * @media screen and (max-width: 1000px) { | |
| * .column { | |
| * width: 100%; | |
| * margin: 0; | |
| * } | |
| * } | |
| * | |
| */ | |
| // Variables | |
| @size__site-main: 1000px; | |
| @breakpoint__papa-bear: @size__site-main; | |
| @breakpoint__mama-bear: @size__site-main * 0.70; // 70% of full-width | |
| @breakpoint__baby-bear: @size__site-main * 0.45; // 45% of full-width | |
| // Mixins | |
| .break(@query, @rules) { | |
| @media screen and @query { | |
| @rules(); | |
| } | |
| } | |
| .break-between(@min, @max, @rules) { | |
| .break(~"(min-width : @{min}) and (max-width : @{max})", @rules); | |
| } | |
| .break-large(@direction, @rules) { | |
| .break(~"(@{direction}-width: @{breakpoint__papa-bear})", @rules); | |
| } | |
| .break-med(@direction, @rules) { | |
| .break(~"(@{direction}-width: @{breakpoint__mama-bear})", @rules); | |
| } | |
| .break-small(@direction, @rules) { | |
| .break(~"(@{direction}-width: @{breakpoint__baby-bear})", @rules); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment