|
// path to local mixin |
|
@import "../../stylesheets/breakpoint"; |
|
// @import "breakpoint"; |
|
|
|
|
|
/* 1. Using Breakpoint to do exactly what you propose */ |
|
$breakpoint-default-media: 'only screen'; |
|
$break-small: 320px; |
|
$break-medium: 580px; |
|
$break-large: 1234px; |
|
$hi-rez: 2 device-pixel-ratio; |
|
|
|
.break-small { |
|
@include breakpoint($break-small max-width) { |
|
content: "break small"; |
|
} |
|
} |
|
.small-screen { |
|
@include breakpoint(($break-small + 1) ($break-medium - 1)) { |
|
content: "small-screen"; |
|
} |
|
} |
|
.medium-screen { |
|
@include breakpoint(($break-medium + 1) ($break-large - 1)) { |
|
content: "medium-screen"; |
|
} |
|
} |
|
.large-screen { |
|
@include breakpoint($break-large) { |
|
content: "large-screen"; |
|
} |
|
} |
|
.retina { |
|
@include breakpoint($hi-rez) { |
|
content: "retina"; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
/* 2. Perhaps a better refactoring */ |
|
$breakpoint-default-media: 'only screen'; |
|
$small-screen: 321px 580px; |
|
$medium-screen: 581px 1233px; |
|
$large-screen: 1234px; |
|
$hi-rez: 2 device-pixel-ratio; |
|
|
|
/* If we assume "mobile first" here, that would |
|
eliminate the first media query */ |
|
.small-screen { |
|
@include breakpoint($small-screen) { |
|
content: "small-screen"; |
|
} |
|
} |
|
.medium-screen { |
|
@include breakpoint($medium-screen) { |
|
content: "medium-screen"; |
|
} |
|
} |
|
.large-screen { |
|
@include breakpoint($large-screen) { |
|
content: "large-screen"; |
|
} |
|
} |
|
.retina { |
|
@include breakpoint($hi-rez) { |
|
content: "retina"; |
|
} |
|
} |
|
|
|
|
|
/* 3. combined queries. */ |
|
$small: 320px; |
|
$medium: 580px; |
|
$large: 1234px; |
|
$extra-large: 1450px; |
|
|
|
|
|
/* passing in two numeric values automatically creates a min/max width */ |
|
.min-max { |
|
@include breakpoint($medium $large) { |
|
content: "min/max width"; |
|
} |
|
} |
|
|
|
|
|
/* you can change the feature with a string */ |
|
$small-height: 400px; |
|
$medium-height: 800px; |
|
.min-max-height { |
|
@include breakpoint($small-height $medium-height height) { |
|
content: "min/max height"; |
|
} |
|
} |
|
|
|
/* you can chain these together with commas. |
|
I make new variables at this point for better readability */ |
|
$medium-width-height: $medium $large, $small-height $medium-height height; |
|
.min-max-width-height { |
|
@include breakpoint($medium-width-height) { |
|
content: "min/max width and height"; |
|
} |
|
} |
|
|
|
/* 4. !not */ |
|
/* We can also add in 'not' and 'only' by passing that in as a second argument. |
|
*/ |
|
$hi-rez: 2 min-device-pixel-ratio; |
|
.not-hi-rez { |
|
@include breakpoint($hi-rez, 'not screen') { |
|
content: "not hi-rez"; |
|
} |
|
} |
|
|