Media Queries
$breakpoints (map)
$breakpoints: () !default;
Establish a map of named breakpoints.
If using Accoutrement Scale,
you can use the scale syntax
for describing size-relationships and adjustments –
and even reference $sizes
as though they are $breakpoints
.
Otherwise, the map should contain only valid CSS length values.
Since 0.1.0
:
- BREAKING: Uses the new shared map syntax, for internal references and adjustments
Examples
tools.$breakpoints: (
'small': 30em,
'medium': 45em,
);
tools.$breakpoints: (
'small': 30em ('convert-units': 'browser-ems'),
'medium': '#small' ('times': 1.5),
);
Related
PX, EM, or REM Media Queries? [external]
@function break()
Return a breakpoint from the $breakpoint
map,
or the Accoutrement-scale $sizes
map if it’s available.
Since 1.0.0
:
- NEW: Accepts
$do
map argument, for on-the-fly adjustments - NEW: Accepts
$source
map argument, for custom breakpoint source-palette - NEW: Accepts
$scale
boolean argument, to turn off access to scale plugin$sizes
map
Parameters & Return
$break: (string)
The name or value of a breakpoint
$do: null (map | null)
A map of function/ratio adjustments to run on the returned value
$source: $breakpoints (map)
Optional Accoutrement-format map of breakpoints to use as the origin palette
$scale: true (boolean)
By default, we merge in any $sizes
available
from the scale plugin –
making both $breakpoints
and $sizes
keys available
@return (length)
The retrieved value of a named breakpoint
@error
$break
is not a valid length or keyword
@mixin below()
Generate a max–<width
/height
> query,
for styling elements below the given viewport width.
To help with overlapping min/max queries,
we remove 1px
(or 0.01em
) from every max value by default.
You can adjust that setting
to adjust min values
or avoid adjustments
using the global $adjust-query-overlap
setting.
Since 2.0.0
:
- BREAKING: min/max adjustments applied to all units (not only px/em/rem)
- NEW: min/max adjustments respect
$adjust-query-overlap
global setting
Parameters
$max: (length | string)
The name of a documented breakpoint/size, or an arbitarty length to use in the query.
$prop: 'width' ('width' | 'height')
The property (width or height) to test against,
for a result of e.g. (max-width: 30em)
.
Examples
@include tools.below(30em) {
html { background: red; }
}
@media (max-width: 29.99em) {
html {
background: red;
}
}
tools.$breakpoints: ('red': 30em);
@include tools.below('red') {
html { background: red; }
}
@media (max-width: 29.99em) {
html {
background: red;
}
}
@mixin above()
Generate a min-<width
/height
> query,
for styling elements above the given viewport width.
To help with overlapping min/max queries,
we remove 1px
(or 0.01em
) from max values by default.
You can adjust that setting
to adjust min values
or avoid adjustments
using the global $adjust-query-overlap
setting.
Since 2.0.0
:
- BREAKING: min/max adjustments applied to all units (not only px/em/rem)
- NEW: min/max adjustments respect
$adjust-query-overlap
global setting
Parameters
$min: (length | string)
The name of a documented breakpoint/size, or an arbitrary length to use in the query.
$prop: 'width' ('width' | 'height')
The property (width or height) to test against,
for a result of e.g. (min-width: 30em)
.
Examples
@include tools.above(50em) {
html { background: green; }
}
@media (min-width: 50em) {
html {
background: green;
}
}
tools.$breakpoints: ('green': 50em);
@include tools.above('green') {
html { background: green; }
}
@media (min-width: 50em) {
html {
background: green;
}
}
@mixin between()
Generate a min-and-max-<width
/height
> query,
for styling elements between given viewport widths.
To help with overlapping min/max queries,
we remove 1px
(or 0.01em
) from every max value by default.
You can adjust that setting
to adjust min values
or avoid adjustments
using the global $adjust-query-overlap
setting.
Since 2.0.0
:
- BREAKING: min/max adjustments applied to all units (not only px/em/rem)
- NEW: min/max adjustments respect
$adjust-query-overlap
global setting
Parameters
$min: (length | string)
The name of a documented breakpoint/size, or an arbitarty length to use as a minimum in the query.
$max: (length | string)
The name of a documented breakpoint/size, or an arbitarty length to use as a maximum in the query.
$prop: 'width' ('width' | 'height')
The property (width or height) to test against,
for a result of e.g. (min-width: 30em)
.
Examples
@include tools.between(30em, 50em) {
html { background: yellow; }
}
@media (min-width: 30em) and (max-width: 49.99em) {
html {
background: yellow;
}
}
tools.$breakpoints: (
'red': 30em,
'green': 50em,
);
@include tools.between('red', 'green') {
html { background: yellow; }
}
@media (min-width: 30em) and (max-width: 49.99em) {
html {
background: yellow;
}
}
Query Utils
$adjust-query-overlap ('min' | 'max' | false)
$adjust-query-overlap: 'max' !default;
When using both min-
and max-
media-queries,
you will often get a 1px
or 1em
overlap
where neither or both queries are applied.
In order to avoid that,
we nudge the max-
value down by default.
Set this variable to min
to nudge min-
values up,
or false
to keep both min and max values un-adjusted,
Since 2.0.0
:
- NEW: Allows you to override global max-adjustment default