1.0.8 • Published 5 years ago

css-convert v1.0.8

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

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 element
    • dpr: Number device pixel ratio that is the ratio between physical pixels and logical pixels
    • compress: 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.

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

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