| 1 | # PostCSS Overflow Shorthand [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]
|
|---|
| 2 |
|
|---|
| 3 | [![NPM Version][npm-img]][npm-url]
|
|---|
| 4 | [![CSS Standard Status][css-img]][css-url]
|
|---|
| 5 | [![Build Status][cli-img]][cli-url]
|
|---|
| 6 | [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
|
|---|
| 7 |
|
|---|
| 8 | [PostCSS Overflow Shorthand] lets you use the `overflow` shorthand in CSS,
|
|---|
| 9 | following the [CSS Overflow] specification.
|
|---|
| 10 |
|
|---|
| 11 | [](https://caniuse.com/#feat=css-overflow)
|
|---|
| 12 |
|
|---|
| 13 | ```pcss
|
|---|
| 14 | html {
|
|---|
| 15 | overflow: hidden auto;
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | /* becomes */
|
|---|
| 19 |
|
|---|
| 20 | html {
|
|---|
| 21 | overflow-x: hidden;
|
|---|
| 22 | overflow-y: auto;
|
|---|
| 23 | overflow: hidden auto;
|
|---|
| 24 | }
|
|---|
| 25 | ```
|
|---|
| 26 |
|
|---|
| 27 | ## Usage
|
|---|
| 28 |
|
|---|
| 29 | Add [PostCSS Overflow Shorthand] to your project:
|
|---|
| 30 |
|
|---|
| 31 | ```bash
|
|---|
| 32 | npm install postcss postcss-overflow-shorthand --save-dev
|
|---|
| 33 | ```
|
|---|
| 34 |
|
|---|
| 35 | Use it as a [PostCSS] plugin:
|
|---|
| 36 |
|
|---|
| 37 | ```js
|
|---|
| 38 | const postcss = require('postcss');
|
|---|
| 39 | const postcssOverflowShorthand = require('postcss-overflow-shorthand');
|
|---|
| 40 |
|
|---|
| 41 | postcss([
|
|---|
| 42 | postcssOverflowShorthand(/* pluginOptions */)
|
|---|
| 43 | ]).process(YOUR_CSS /*, processOptions */);
|
|---|
| 44 | ```
|
|---|
| 45 |
|
|---|
| 46 | [PostCSS Overflow Shorthand] runs in all Node environments, with special
|
|---|
| 47 | instructions for:
|
|---|
| 48 |
|
|---|
| 49 | | [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) |
|
|---|
| 50 | | --- | --- | --- | --- | --- | --- |
|
|---|
| 51 |
|
|---|
| 52 | ## Options
|
|---|
| 53 |
|
|---|
| 54 | ### preserve
|
|---|
| 55 |
|
|---|
| 56 | The `preserve` option determines whether the original `overflow` declaration is
|
|---|
| 57 | preserved. By default, it is preserved.
|
|---|
| 58 |
|
|---|
| 59 | ```js
|
|---|
| 60 | postcssOverflowShorthand({ preserve: false })
|
|---|
| 61 | ```
|
|---|
| 62 |
|
|---|
| 63 | ```pcss
|
|---|
| 64 | html {
|
|---|
| 65 | overflow: hidden auto;
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | /* becomes */
|
|---|
| 69 |
|
|---|
| 70 | html {
|
|---|
| 71 | overflow-x: hidden;
|
|---|
| 72 | overflow-y: auto;
|
|---|
| 73 | }
|
|---|
| 74 | ```
|
|---|
| 75 |
|
|---|
| 76 | [cli-img]: https://github.com/csstools/postcss-plugins/workflows/test/badge.svg
|
|---|
| 77 | [cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
|
|---|
| 78 | [css-img]: https://cssdb.org/images/badges/overflow-property.svg
|
|---|
| 79 | [css-url]: https://cssdb.org/#overflow-property
|
|---|
| 80 | [discord]: https://discord.gg/bUadyRwkJS
|
|---|
| 81 | [npm-img]: https://img.shields.io/npm/v/postcss-overflow-shorthand.svg
|
|---|
| 82 | [npm-url]: https://www.npmjs.com/package/postcss-overflow-shorthand
|
|---|
| 83 |
|
|---|
| 84 | [CSS Overflow]: https://drafts.csswg.org/css-overflow/#propdef-overflow
|
|---|
| 85 | [Gulp PostCSS]: https://github.com/postcss/gulp-postcss
|
|---|
| 86 | [Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
|
|---|
| 87 | [PostCSS]: https://github.com/postcss/postcss
|
|---|
| 88 | [PostCSS Loader]: https://github.com/postcss/postcss-loader
|
|---|
| 89 | [PostCSS Overflow Shorthand]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-overflow-shorthand
|
|---|