css-convert
v1.0.8
Published
Convert unit (px to rem) in css code based on [css parser / stringifier](https://github.com/reworkcss/css)
Downloads
3
Readme
css-convert
Convert unit (px to rem) in css code based on CSS parser / stringifier
Supports
- px to rem
Install
npm i css-convert
Usage
px to rem
import { px2rem } from 'css-convert';
const result = px2rem('body { width: 750px }', {
rem: 16,
dpr: 2,
compress: true,
});
px2rem(code, options = {})
code: String
source css code.option: Object
rem: Number
font size of root elementdpr: Number
device pixel ratio that is the ratio between physical pixels and logical pixelscompress: Bool
compress the result css code
Ignore
Add /*px*/
after declaration on the same line.
img {
width: 10px; /*px*/
}
border
related css props are already ignored.