@pacote/pixels v2.0.4
@pacote/pixels
Convert CSS length values to pixels.
Installation
yarn add @pacote/pixelsUsage
import { pixels } from '@pacote/pixels'
// When the root element has `font-size: 16px`.
pixels('2rem') // => 32pixels(value: string): number
pixels() takes a CSS string with the value and unit and converts it to pixels.
Handles common font-relative units (em, rem, vw, vh, vmin, and vmax)
as well as most absolute units (px, cm, mm, Q, in, pt, and pc).
The function does not handle percentage lengths as resolution depends on the
relative sizes of specific properties of elements up the DOM tree. For example,
font-size is relative to the parent element's font-size but max-height is
relative to the containing element's height.
License
MIT © Luís Rodrigues.
9 months ago
1 year ago
2 years ago
3 years ago
3 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago