UNPKG

1.91 kBMarkdownView Raw
1# [postcss][postcss]-convert-values
2
3> Convert values with PostCSS (e.g. ms -> s)
4
5## Install
6
7With [npm](https://npmjs.org/package/postcss-convert-values) do:
8
9```
10npm install postcss-convert-values --save
11```
12
13## Example
14
15This plugin reduces CSS size by converting values to use different units
16where possible; for example, `500ms` can be represented as `.5s`. You can
17read more about these units in [this article][csstricks].
18
19### Input
20
21```css
22h1 {
23 font-size: 16px;
24 width: 0em
25}
26```
27
28### Output
29
30```css
31h1 {
32 font-size: 1pc;
33 width: 0
34}
35```
36
37Note that this plugin only covers conversions for duration and absolute length
38values. For color conversions, use [postcss-colormin][colormin].
39
40## API
41
42### convertValues([options])
43
44#### options
45
46##### length
47
48Type: `boolean`
49Default: `true`
50
51Pass `false` to disable conversion from `px` to other absolute length units,
52such as `pc` & `pt` & vice versa.
53
54##### time
55
56Type: `boolean`
57Default: `true`
58
59Pass `false` to disable conversion from `ms` to `s` & vice versa.
60
61##### angle
62
63Type: `boolean`
64Default: `true`
65
66Pass `false` to disable conversion from `deg` to `turn` & vice versa.
67
68##### precision
69
70Type: `boolean|number`
71Default: `false`
72
73Specify any numeric value here to round `px` values to that many decimal places;
74for example, using `{precision: 2}` will round `6.66667px` to `6.67px`, and
75`{precision: 0}` will round it to `7px`. Passing `false` (the default) will
76leave these values as is.
77
78It is recommended for most use cases to set this option to `2`.
79
80
81## Usage
82
83See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
84examples for your environment.
85
86
87## Contributors
88
89See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).
90
91
92## License
93
94MIT © [Ben Briggs](http://beneb.info)
95
96
97[postcss]: https://github.com/postcss/postcss
98[csstricks]: https://css-tricks.com/the-lengths-of-css/