Created
September 29, 2017 17:12
-
-
Save hutch78/1583443a3080634b16a8354144568d6c to your computer and use it in GitHub Desktop.
Media Query Variables, range functions, etc. Borrowed from Foundation.
This file contains 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
// - - - - - - - - - - - - - - - - - - - - - - - - - | |
// Media Query Ranges | |
// - usage: | |
// @media #{$large-up}{ | |
// // styles here | |
// } | |
// - - - - - - - - - - - - - - - - - - - - - - - - - | |
// Tools | |
// We use these functions to define ranges for media queries. | |
@function lower-bound($range){ | |
@if length($range) <= 0 { | |
@return 0; | |
} | |
@return nth($range,1); | |
} | |
@function upper-bound($range) { | |
@if length($range) < 2 { | |
@return 999999999999; | |
} | |
@return nth($range, 2); | |
} | |
$small-range: (0em, 40em); | |
$medium-range: (40.063em, 64em); | |
$large-range: (64.063em, 90em); | |
$xlarge-range: (90.063em, 120em); | |
$xxlarge-range: (120.063em, 99999999em); | |
$screen: "only screen"; | |
$landscape: "#{$screen} and (orientation: landscape)"; | |
$portrait: "#{$screen} and (orientation: portrait)"; | |
$small-up: $screen; | |
$small-only: "#{$screen} and (max-width: #{upper-bound($small-range)})"; | |
$medium-up: "#{$screen} and (min-width:#{lower-bound($medium-range)})"; | |
$medium-only: "#{$screen} and (min-width:#{lower-bound($medium-range)}) and (max-width:#{upper-bound($medium-range)})"; | |
$large-up: "#{$screen} and (min-width:#{lower-bound($large-range)})"; | |
$large-down: "#{$screen} and (max-width:#{upper-bound($medium-range)})"; | |
$large-only: "#{$screen} and (min-width:#{lower-bound($large-range)}) and (max-width:#{upper-bound($large-range)})"; | |
$xlarge-up: "#{$screen} and (min-width:#{lower-bound($xlarge-range)})"; | |
$xlarge-only: "#{$screen} and (min-width:#{lower-bound($xlarge-range)}) and (max-width:#{upper-bound($xlarge-range)})"; | |
$xxlarge-up: "#{$screen} and (min-width:#{lower-bound($xxlarge-range)})"; | |
$xxlarge-only: "#{$screen} and (min-width:#{lower-bound($xxlarge-range)}) and (max-width:#{upper-bound($xxlarge-range)})"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment