Converting Units
@function convert-units()
Convert lengths between comparable units.
You can also convert to browser-ems
,
relative to the browser default rather than the site root –
useful for media queries.
Aliased as convert-units
, convert
, units
, and to
in all Accoutrement maps.
Since 1.0.0
:
- NEW: Aliased as
to
in Accoutrement-maps
Parameters & Return
$length: (length | string)
The length or named size to be converted.
$to-unit: (string)
The desired units to convert to.
Some units (ch
, vw
, vh
, vmin
, vmax
) cannot be converted.
$from-context: false (length | string)
When converting from relative units,
the absolute length (in px) to which $length refers -
e.g. for $lengths
in em units, would normally be the
font-size of the current element.
false
and null
will resolve to your ‘root’ setting or 16px
$to-context: $from-context (length | string)
For converting to relative units,
the absolute length in px to which the output value will refer.
Defaults to the same as $from-context
, since it is rarely needed.
@error
Context parameters must resolve to a value in pixel units