source: frontend/node_modules/css-blank-pseudo/README.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.6 KB
Line 
1# CSS Blank Pseudo [<img src="http://jonathantneal.github.io/js-logo.svg" alt="" width="90" height="90" align="right">][CSS Blank Pseudo]
2
3[![NPM Version][npm-img]][npm-url]
4[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
5
6[CSS Blank Pseudo] lets you style form elements when they are empty, following
7the [Selectors Level 4] specification.
8
9```css
10input {
11 /* style an input */
12}
13
14input:blank {
15 /* style an input without a value */
16}
17```
18
19## Usage
20
21From the command line, transform CSS files that use `:blank` selectors:
22
23```bash
24npx css-blank-pseudo SOURCE.css --output TRANSFORMED.css
25```
26
27Next, use your transformed CSS with this script:
28
29```html
30<link rel="stylesheet" href="TRANSFORMED.css">
31<script src="https://unpkg.com/css-blank-pseudo/dist/browser-global.js"></script>
32<script>cssBlankPseudo(document)</script>
33```
34
35⚠️ Please use a versioned url, like this : `https://unpkg.com/css-blank-pseudo@3.0.0/dist/browser-global.js`
36Without the version, you might unexpectedly get a new major version of the library with breaking changes.
37
38⚠️ If you were using an older version via a CDN, please update the entire url.
39The old URL will no longer work in a future release.
40
41That’s it. The script works in most browsers.
42
43## How it works
44
45The [PostCSS plugin](README-POSTCSS.md) clones rules containing `:blank`,
46replacing them with an alternative `[blank]` selector.
47
48```css
49input:blank {
50 background-color: yellow;
51}
52
53/* becomes */
54
55input[blank] {
56 background-color: yellow;
57}
58
59input:blank {
60 background-color: yellow;
61}
62```
63
64Next, the [JavaScript library](README-BROWSER.md) adds a `blank` attribute to
65elements otherwise matching `:blank` natively.
66
67```html
68<input value="" blank>
69<input value="This element has a value">
70```
71
72## ⚠️ `:not(:blank)`
73
74with option : `preserve` `true`
75
76```css
77input:not(:blank) {
78 background-color: yellow;
79}
80
81/* becomes */
82
83input:not([blank]) {
84 background-color: yellow;
85}
86
87input:not(:blank) {
88 background-color: yellow;
89}
90```
91
92When you do not include the JS polyfill one will always match in browsers that support `:blank` natively.
93In browsers that do not support `:blank` natively the rule will be invalid.
94
95_currently no browsers support `:blank`_
96
97
98[discord]: https://discord.gg/bUadyRwkJS
99[npm-img]: https://img.shields.io/npm/v/css-blank-pseudo.svg
100[npm-url]: https://www.npmjs.com/package/css-blank-pseudo
101
102[CSS Blank Pseudo]: https://github.com/csstools/postcss-plugins/tree/main/plugins/css-blank-pseudo
103[PostCSS Preset Env]: https://preset-env.cssdb.org/
104[Selectors Level 4]: https://drafts.csswg.org/selectors-4/#blank
Note: See TracBrowser for help on using the repository browser.