Skip to main content

Module units

Module units 

Source
Expand description

CSS length/percentage units.

Supports: px, %, em, rem, vw, vh, fr, auto, plus a bare number (interpreted as px).

Resolution to absolute pixels happens through LengthContext, which carries the viewport dimensions, parent size (for %), and font sizes (for em / rem).

Structs§

LengthContext

Enums§

Length
A pure CSS length, no percentage allowed (e.g. font-size, box-shadow).
LengthPercentage
A CSS length OR percentage (e.g. width, padding, top).
ParsedLength
Internal parsed representation. Once parsed we know which unit it is.

Functions§

parse_length
Parse a CSS length/percentage string. Whitespace tolerated.
parse_origin_component
Parse a CSS length/percentage string that may also contain transform-origin axis keywords (left, center, right, top, bottom).