https://github.com/matype/css-unit
Analize CSS values and units
https://github.com/matype/css-unit
Last synced: 9 months ago
JSON representation
Analize CSS values and units
- Host: GitHub
- URL: https://github.com/matype/css-unit
- Owner: matype
- License: other
- Created: 2014-05-05T02:37:51.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-05-14T18:16:29.000Z (about 12 years ago)
- Last Synced: 2024-06-01T06:12:51.642Z (about 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 535 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.markdown
- License: LICENSE
Awesome Lists containing this project
README
# css-unit [](https://travis-ci.org/morishitter/css-unit)
Analize CSS values and units.
## Installation
```
npm install css-unit
```
## Example
```javascript
var unit = require('css-unit');
var value = '50px';
var css = '.site-nav > li:hover .dropdown{position:absolute;top:37px;left:0;}';
unit.is(value); // 'px'
unit.rm(value); // 50
unit.stats(css);
/*
{ num: 2,
units: [ 'px', 'none' ],
rules:
[ { type: 'rule',
selectors: [ '.site-nav > li:hover .dropdown' ],
declarations:
[ { type: 'declaration',
property: 'top',
value: '37px',
num: 37,
unit: 'px' },
{ type: 'declaration',
property: 'left',
value: '0',
num: 0,
unit: 'none' } ] } ] }
*/
```
## License
The MIT License (MIT)
Copyright (c) 2014 Masaaki Morishita