zurb-foundation-5
Version:
Foundation 5 for npm (no code modification from original repo)
100 lines (65 loc) • 3.34 kB
HTML
---
title: Media Queries
---
<h3 class="subheader">We keep media queries fairly simple in Foundation and let the percentage-based grid do the heavy lifting across various screen sizes.</h3>
***
<h3>Basic</h3>
Media queries are built using ems in Foundation.
<h4>CSS</h4>
```scss
// Small screens
only screen { } /* Define mobile styles */
only screen and (max-width: 40em) { } /* max-width 640px, mobile-only styles, use when QAing mobile issues */
// Medium screens
only screen and (min-width: 40.063em) { } /* min-width 641px, medium screens */
only screen and (min-width: 40.063em) and (max-width: 64em) { } /* min-width 641px and max-width 1024px, use when QAing tablet-only issues */
// Large screens
only screen and (min-width: 64.063em) { } /* min-width 1025px, large screens */
only screen and (min-width: 64.063em) and (max-width: 90em) { } /* min-width 1025px and max-width 1440px, use when QAing large screen-only issues */
// XLarge screens
only screen and (min-width: 90.063em) { } /* min-width 1441px, xlarge screens */
only screen and (min-width: 90.063em) and (max-width: 120em) { } /* min-width 1441px and max-width 1920px, use when QAing xlarge screen-only issues */
// XXLarge screens
only screen and (min-width: 120.063em) { } /* min-width 1921px, xxlarge screens */
```
***
### Customize With Sass
Media queries can be easily customized by changing the variable values in `_settings.scss`.
<h4>SCSS</h4>
```scss
// Here we define the lower and upper bounds for each media size
$small-range: (0em, 40em); /* 0, 640px */
$medium-range: (40.063em, 64em); /* 641px, 1024px */
$large-range: (64.063em, 90em); /* 1025px, 1440px */
$xlarge-range: (90.063em, 120em); /* 1441px, 1920px */
$xxlarge-range: (120.063em); /* 1921px */
// Media Queries
$screen: "only screen" !default;
$landscape: "#{$screen} and (orientation: landscape)" !default;
$portrait: "#{$screen} and (orientation: portrait)" !default;
$small-up: $screen !default;
$small-only: "#{$screen} and (max-width: #{upper-bound($small-range)})" !default;
$medium-up: "#{$screen} and (min-width:#{lower-bound($medium-range)})" !default;
$medium-only: "#{$screen} and (min-width:#{lower-bound($medium-range)}) and (max-width:#{upper-bound($medium-range)})" !default;
$large-up: "#{$screen} and (min-width:#{lower-bound($large-range)})" !default;
$large-only: "#{$screen} and (min-width:#{lower-bound($large-range)}) and (max-width:#{upper-bound($large-range)})" !default;
$xlarge-up: "#{$screen} and (min-width:#{lower-bound($xlarge-range)})" !default;
$xlarge-only: "#{$screen} and (min-width:#{lower-bound($xlarge-range)}) and (max-width:#{upper-bound($xlarge-range)})" !default;
$xxlarge-up: "#{$screen} and (min-width:#{lower-bound($xxlarge-range)})" !default;
$xxlarge-only: "#{$screen} and (min-width:#{lower-bound($xxlarge-range)}) and (max-width:#{upper-bound($xxlarge-range)})" !default;
```
<h3>Style With Sass</h3>
Use these media queries with the variables specified above.
<h4>SCSS</h4>
```scss
#{$small-up} { }
#{$small-only} { }
#{$medium-up} { }
#{$medium-only} { }
#{$large-up} { }
#{$large-only} { }
#{$xlarge-up} { }
#{$xlarge-only} { }
#{$xxlarge-up} { }
#{$xxlarge-only} { }
```