[6a3a178] | 1 | # PostCSS Double Position Gradients [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS" width="90" height="90" align="right">][postcss]
|
---|
| 2 |
|
---|
| 3 | [![NPM Version][npm-img]][npm-url]
|
---|
| 4 | [![Build Status][cli-img]][cli-url]
|
---|
| 5 | [![Support Chat][git-img]][git-url]
|
---|
| 6 |
|
---|
| 7 | [PostCSS Double Position Gradients] lets you use double-position gradients in
|
---|
| 8 | CSS, following the [CSS Image Values and Replaced Content] specification.
|
---|
| 9 |
|
---|
| 10 | ```pcss
|
---|
| 11 | .linear-gradient {
|
---|
| 12 | background-image: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | .conic-gradient {
|
---|
| 16 | background-image: conic-gradient(yellowgreen 40%, gold 0deg 75%, #f06 0deg);
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | /* becomes */
|
---|
| 20 |
|
---|
| 21 | .linear-gradient {
|
---|
| 22 | background-image: linear-gradient(90deg, black 25%, black 50%, blue 50%, blue 75%);
|
---|
| 23 | background-image: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | .conic-gradient {
|
---|
| 27 | background-image: conic-gradient(yellowgreen 40%, gold 0deg, gold 75%, #f06 0deg);
|
---|
| 28 | background-image: conic-gradient(yellowgreen 40%, gold 0deg 75%, #f06 0deg);
|
---|
| 29 | }
|
---|
| 30 | ```
|
---|
| 31 |
|
---|
| 32 | ## Usage
|
---|
| 33 |
|
---|
| 34 | Add [PostCSS Double Position Gradients] to your project:
|
---|
| 35 |
|
---|
| 36 | ```bash
|
---|
| 37 | npm install postcss-double-position-gradients --save-dev
|
---|
| 38 | ```
|
---|
| 39 |
|
---|
| 40 | Use [PostCSS Double Position Gradients] to process your CSS:
|
---|
| 41 |
|
---|
| 42 | ```js
|
---|
| 43 | const postcssDoublePositionGradients = require('postcss-double-position-gradients');
|
---|
| 44 |
|
---|
| 45 | postcssDoublePositionGradients.process(YOUR_CSS /*, processOptions, pluginOptions */);
|
---|
| 46 | ```
|
---|
| 47 |
|
---|
| 48 | Or use it as a [PostCSS] plugin:
|
---|
| 49 |
|
---|
| 50 | ```js
|
---|
| 51 | const postcss = require('postcss');
|
---|
| 52 | const postcssDoublePositionGradients = require('postcss-double-position-gradients');
|
---|
| 53 |
|
---|
| 54 | postcss([
|
---|
| 55 | postcssDoublePositionGradients(/* pluginOptions */)
|
---|
| 56 | ]).process(YOUR_CSS /*, processOptions */);
|
---|
| 57 | ```
|
---|
| 58 |
|
---|
| 59 | [PostCSS Double Position Gradients] runs in all Node environments, with special instructions for:
|
---|
| 60 |
|
---|
| 61 | | [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) |
|
---|
| 62 | | --- | --- | --- | --- | --- | --- |
|
---|
| 63 |
|
---|
| 64 | ## Options
|
---|
| 65 |
|
---|
| 66 | ### preserve
|
---|
| 67 |
|
---|
| 68 | The `preserve` option determines whether the original double-position gradients
|
---|
| 69 | should be preserved. By default, double-position gradients are preserved.
|
---|
| 70 |
|
---|
| 71 | ```js
|
---|
| 72 | postcssDoublePositionGradients({ preserve: false })
|
---|
| 73 | ```
|
---|
| 74 |
|
---|
| 75 | ```css
|
---|
| 76 | .linear-gradient {
|
---|
| 77 | background-image: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | .conic-gradient {
|
---|
| 81 | background-image: conic-gradient(yellowgreen 40%, gold 0deg 75%, #f06 0deg);
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | /* becomes */
|
---|
| 85 |
|
---|
| 86 | .linear-gradient {
|
---|
| 87 | background-image: linear-gradient(90deg, black 25%, black 50%, blue 50%, blue 75%);
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | .conic-gradient {
|
---|
| 91 | background-image: conic-gradient(yellowgreen 40%, gold 0deg, gold 75%, #f06 0deg);
|
---|
| 92 | }
|
---|
| 93 | ```
|
---|
| 94 |
|
---|
| 95 | [cli-img]: https://img.shields.io/travis/jonathantneal/postcss-double-position-gradients/master.svg
|
---|
| 96 | [cli-url]: https://travis-ci.org/jonathantneal/postcss-double-position-gradients
|
---|
| 97 | [git-img]: https://img.shields.io/badge/support-chat-blue.svg
|
---|
| 98 | [git-url]: https://gitter.im/postcss/postcss
|
---|
| 99 | [npm-img]: https://img.shields.io/npm/v/postcss-double-position-gradients.svg
|
---|
| 100 | [npm-url]: https://www.npmjs.com/package/postcss-double-position-gradients
|
---|
| 101 |
|
---|
| 102 | [CSS Image Values and Replaced Content]: https://www.w3.org/TR/css-images-4/#color-stop-syntax
|
---|
| 103 | [PostCSS]: https://github.com/postcss/postcss
|
---|
| 104 | [PostCSS Double Position Gradients]: https://github.com/jonathantneal/postcss-double-position-gradients
|
---|