[6a3a178] | 1 | # PostCSS Pseudo Class Any Link [<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 | [![Support Chat][git-img]][git-url]
|
---|
| 7 |
|
---|
| 8 | [PostCSS Pseudo Class Any Link] lets you `:any-link` pseudo-class in CSS,
|
---|
| 9 | following the [Selectors] specification.
|
---|
| 10 |
|
---|
| 11 | ```pcss
|
---|
| 12 | nav :any-link > span {
|
---|
| 13 | background-color: yellow;
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | /* becomes */
|
---|
| 17 |
|
---|
| 18 | nav :link > span, nav :visited > span {
|
---|
| 19 | background-color: yellow;
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | nav :any-link > span {
|
---|
| 23 | background-color: yellow;
|
---|
| 24 | }
|
---|
| 25 | ```
|
---|
| 26 |
|
---|
| 27 | From the [proposal][Selectors]:
|
---|
| 28 |
|
---|
| 29 | > The `:any-link` pseudo-class represents an element that acts as the source
|
---|
| 30 | anchor of a hyperlink. It matches an element if the element would match
|
---|
| 31 | `:link` or `:visited`.
|
---|
| 32 |
|
---|
| 33 | ## Usage
|
---|
| 34 |
|
---|
| 35 | Add [PostCSS Pseudo Class Any Link] to your project:
|
---|
| 36 |
|
---|
| 37 | ```bash
|
---|
| 38 | npm install postcss-pseudo-class-any-link --save-dev
|
---|
| 39 | ```
|
---|
| 40 |
|
---|
| 41 | Use [PostCSS Pseudo Class Any Link] to process your CSS:
|
---|
| 42 |
|
---|
| 43 | ```js
|
---|
| 44 | const postcssPseudoClassAnyLink = require('postcss-pseudo-class-any-link');
|
---|
| 45 |
|
---|
| 46 | postcssPseudoClassAnyLink.process(YOUR_CSS /*, processOptions, pluginOptions */);
|
---|
| 47 | ```
|
---|
| 48 |
|
---|
| 49 | Or use it as a [PostCSS] plugin:
|
---|
| 50 |
|
---|
| 51 | ```js
|
---|
| 52 | const postcss = require('postcss');
|
---|
| 53 | const postcssPseudoClassAnyLink = require('postcss-pseudo-class-any-link');
|
---|
| 54 |
|
---|
| 55 | postcss([
|
---|
| 56 | postcssPseudoClassAnyLink(/* pluginOptions */)
|
---|
| 57 | ]).process(YOUR_CSS /*, processOptions */);
|
---|
| 58 | ```
|
---|
| 59 |
|
---|
| 60 | [PostCSS Pseudo Class Any Link] runs in all Node environments, with special
|
---|
| 61 | instructions for:
|
---|
| 62 |
|
---|
| 63 | | [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) |
|
---|
| 64 | | --- | --- | --- | --- | --- | --- |
|
---|
| 65 |
|
---|
| 66 | ## Options
|
---|
| 67 |
|
---|
| 68 | ### preserve
|
---|
| 69 |
|
---|
| 70 | The `preserve` option determines whether the original `:any-link` rule is
|
---|
| 71 | preserved. By default, it is preserved.
|
---|
| 72 |
|
---|
| 73 | ```js
|
---|
| 74 | postcssPseudoClassAnyLink({ preserve: false })
|
---|
| 75 | ```
|
---|
| 76 |
|
---|
| 77 | ```pcss
|
---|
| 78 | nav :any-link > span {
|
---|
| 79 | background-color: yellow;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | /* becomes */
|
---|
| 83 |
|
---|
| 84 | nav :link > span, nav :visited > span {
|
---|
| 85 | background-color: yellow;
|
---|
| 86 | }
|
---|
| 87 | ```
|
---|
| 88 |
|
---|
| 89 | [cli-img]: https://img.shields.io/travis/jonathantneal/postcss-pseudo-class-any-link.svg
|
---|
| 90 | [cli-url]: https://travis-ci.org/jonathantneal/postcss-pseudo-class-any-link
|
---|
| 91 | [css-img]: https://cssdb.org/badge/any-link-pseudo-class.svg
|
---|
| 92 | [css-url]: https://cssdb.org/#any-link-pseudo-class
|
---|
| 93 | [git-img]: https://img.shields.io/badge/support-chat-blue.svg
|
---|
| 94 | [git-url]: https://gitter.im/postcss/postcss
|
---|
| 95 | [npm-img]: https://img.shields.io/npm/v/postcss-pseudo-class-any-link.svg
|
---|
| 96 | [npm-url]: https://www.npmjs.com/package/postcss-pseudo-class-any-link
|
---|
| 97 |
|
---|
| 98 | [Gulp PostCSS]: https://github.com/postcss/gulp-postcss
|
---|
| 99 | [Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
|
---|
| 100 | [PostCSS]: https://github.com/postcss/postcss
|
---|
| 101 | [PostCSS Loader]: https://github.com/postcss/postcss-loader
|
---|
| 102 | [PostCSS Pseudo Class Any Link]: https://github.com/jonathantneal/postcss-pseudo-class-any-link
|
---|
| 103 | [Selectors]: https://www.w3.org/TR/selectors-4/#the-any-link-pseudo
|
---|