| [9af201e] | 1 | # PostCSS Normalize Display Values [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]
|
|---|
| 2 |
|
|---|
| 3 | [<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/postcss-normalize-display-values.svg" height="20">][npm-url]
|
|---|
| 4 | [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/display-two-values.svg" height="20">][css-url]
|
|---|
| 5 | [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url]
|
|---|
| 6 | [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
|
|---|
| 7 |
|
|---|
| 8 | [PostCSS Normalize Display Values] lets you specify definition of outer and inner displays types for an element.
|
|---|
| 9 |
|
|---|
| 10 | ```pcss
|
|---|
| 11 | .element {
|
|---|
| 12 | display: inline flow-root;
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | /* becomes */
|
|---|
| 16 |
|
|---|
| 17 | .element {
|
|---|
| 18 | display: inline-block;
|
|---|
| 19 | display: inline flow-root;
|
|---|
| 20 | }
|
|---|
| 21 | ```
|
|---|
| 22 |
|
|---|
| 23 | _See prior work by [cssnano](https://github.com/cssnano) here [postcss-normalize-display-values](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-display-values)
|
|---|
| 24 | To ensure long term maintenance and to provide the needed features this plugin was recreated based on cssnano's work._
|
|---|
| 25 |
|
|---|
| 26 | ## Usage
|
|---|
| 27 |
|
|---|
| 28 | Add [PostCSS Normalize Display Values] to your project:
|
|---|
| 29 |
|
|---|
| 30 | ```bash
|
|---|
| 31 | npm install postcss @csstools/postcss-normalize-display-values --save-dev
|
|---|
| 32 | ```
|
|---|
| 33 |
|
|---|
| 34 | Use it as a [PostCSS] plugin:
|
|---|
| 35 |
|
|---|
| 36 | ```js
|
|---|
| 37 | const postcss = require('postcss');
|
|---|
| 38 | const postcssNormalizeDisplayValues = require('@csstools/postcss-normalize-display-values');
|
|---|
| 39 |
|
|---|
| 40 | postcss([
|
|---|
| 41 | postcssNormalizeDisplayValues(/* pluginOptions */)
|
|---|
| 42 | ]).process(YOUR_CSS /*, processOptions */);
|
|---|
| 43 | ```
|
|---|
| 44 |
|
|---|
| 45 | [PostCSS Normalize Display Values] runs in all Node environments, with special
|
|---|
| 46 | instructions for:
|
|---|
| 47 |
|
|---|
| 48 | | [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
|
|---|
| 49 | | --- | --- | --- | --- | --- | --- |
|
|---|
| 50 |
|
|---|
| 51 | ## Options
|
|---|
| 52 |
|
|---|
| 53 | ### preserve
|
|---|
| 54 |
|
|---|
| 55 | The `preserve` option determines whether the original source
|
|---|
| 56 | is preserved. By default, it is preserved.
|
|---|
| 57 |
|
|---|
| 58 | ```js
|
|---|
| 59 | postcssNormalizeDisplayValues({ preserve: false })
|
|---|
| 60 | ```
|
|---|
| 61 |
|
|---|
| 62 | ```pcss
|
|---|
| 63 | .element {
|
|---|
| 64 | display: inline flow-root;
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | /* becomes */
|
|---|
| 68 |
|
|---|
| 69 | .element {
|
|---|
| 70 | display: inline-block;
|
|---|
| 71 | }
|
|---|
| 72 | ```
|
|---|
| 73 |
|
|---|
| 74 | [postcss]: https://github.com/postcss/postcss
|
|---|
| 75 |
|
|---|
| 76 | [cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
|
|---|
| 77 | [css-url]: https://cssdb.org/#display-two-values
|
|---|
| 78 | [discord]: https://discord.gg/bUadyRwkJS
|
|---|
| 79 | [npm-url]: https://www.npmjs.com/package/@csstools/postcss-normalize-display-values
|
|---|
| 80 |
|
|---|
| 81 | [CSS Fonts]: https://www.w3.org/TR/css-display-3/#the-display-properties
|
|---|
| 82 | [Gulp PostCSS]: https://github.com/postcss/gulp-postcss
|
|---|
| 83 | [Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
|
|---|
| 84 | [PostCSS]: https://github.com/postcss/postcss
|
|---|
| 85 | [PostCSS Loader]: https://github.com/postcss/postcss-loader
|
|---|
| 86 | [PostCSS Normalize Display Values]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-normalize-display-values
|
|---|