2.0.2 • Published 9 months ago

@pacote/pixels v2.0.2

Weekly downloads
143
License
MIT
Repository
github
Last release
9 months ago

@pacote/pixels

version minified minified + gzip

Convert CSS length values to pixels.

Installation

yarn add @pacote/pixels

Usage

import { pixels } from '@pacote/pixels'

// When the root element has `font-size: 16px`.
pixels('2rem') // => 32

pixels(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.

2.0.2

9 months ago

2.0.1

1 year ago

2.0.0

1 year ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

1.0.0-alpha.1

5 years ago

1.0.0-alpha.0

5 years ago