Get unit from a CSS value
var unit = // => 'px' // => 'kHz' // => null
This module gets unit from the CSS value without verifying. If there is no unit it will return null
. To get the number instead, just use parseFloat
:
var value = '100px' // User css-get-unit to get unit:var unit = // => 'px' // Use parseFloat to get number:var number = // => 100
Installation
$ npm install --save css-get-unit
Usage
unit(value)
value
(String
): CSS value to get the unit from
// => 'px' // => 'ms' // => null
License
MIT © Jamen Marz