pxrem
PostCSS plugin that transforming css from px to rem.
It's also avaliable as:
Getting Started
$ npm i --save-dev cupools/pxrem
var pxrem = var option = root: 75 filter: /^border/ pxrem//=> '.foo { width: 1rem; border: 1px solid #000; }'
Options
- root: root value from px to rem, default to 75
- fixed: precision of rem value, default to 6
- filter: css declaration that should be ignored, can be regexp or function, default to null
- keepPx: keep px for compatible in old browsers, default to false
- commentFilter: the comment that after css declaration which should be ignored, default to 'no'
- enable: enable the plugin, default to true
Examples
1px
Ignore border's width as var pxrem = var content = var option = root: 75 fixed: 6 { if prop === 'border' && value === 0 return true return false } var result = pxremconsole
/* source */ /* output */
For old browsers which not support rem
var pxrem = var content = var option = keepPx: true var result = pxremconsole
/* source */ /* output */
Test
$ npm i && npm test
License
Copyright (c) 2016 cupools
Licensed under the MIT license.