Skip to content

Instantly share code, notes, and snippets.

@kevin-ashton
Last active August 29, 2015 14:19
Show Gist options
  • Save kevin-ashton/c5ac37cd9a824253a9dc to your computer and use it in GitHub Desktop.
Save kevin-ashton/c5ac37cd9a824253a9dc to your computer and use it in GitHub Desktop.
Foundation Media Queries
//Media query logic modifed from Zurbs Foundation framework
$breakpoint-small-max: 600;
$breakpoint-medium-max: 1000;
$breakpoint-large-max: 1339;
$breakpoint-xlarge-max: 1600;
$breakpoint-xxlarge-max: 9999999999;
@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);
}
// Media Query Ranges
$small-range: (0px, $breakpoint-small-max + px) !default;
$medium-range: ($breakpoint-small-max + 1 + px, $breakpoint-medium-max + px) !default;
$large-range: ($breakpoint-medium-max + 1 + px, $breakpoint-large-max + px) !default;
$xlarge-range: ($breakpoint-large-max + 1 + px, $breakpoint-xlarge-max + px) !default;
$xxlarge-range: ($breakpoint-xlarge-max + 1 + px, $breakpoint-xxlarge-max + px) !default;
$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;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div class="exampleList">
<div class="exampleList__header">Cool Header</div>
<div class="exampleList__content">
<div class="exampleList__item"><img src='http://lorempixel.com/500/500/animals/' /></div>
<div class="exampleList__item"><img src='http://lorempixel.com/500/500/city/' /></div>
<div class="exampleList__item"><img src='http://lorempixel.com/500/500/cats/' /></div>
<div class="exampleList__item"><img src='http://lorempixel.com/500/500/people/' /></div>
<div class="exampleList__item"><img src='http://lorempixel.com/500/500/nature/' /></div>
<div class="exampleList__item"><img src='http://lorempixel.com/500/500/food/' /></div>
</div>
</div>
</body>
</html>
.exampleList{
&__header{
font-weight: bold;
font-size: 15px;
font-family: arial;
text-align: center;
margin-bottom: 10px;
@media #{$medium-up} {
font-size: 35px;
margin-bottom: 15px;
}
@media #{$xlarge-up} {
font-size: 72px;
margin-bottom: 20px;
}
}
&__item{
text-align: center;
img{
width: 200px;
height: 200px;
}
@media #{$medium-up} {
float: left;
margin: 0 10px 10px 0;
display: inline-block;
img{
width: 300px;
height: 300px;
}
}
@media #{$xlarge-up} {
img{
width: 400px;
height: 400px;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment