diff --git a/index.html b/index.html index ec1680849..f1c3fa0da 100644 --- a/index.html +++ b/index.html @@ -57,6 +57,10 @@ Popout menu Sibling fade +
@@ -83,6 +87,8 @@ animation +

Bouncing loaderanimation

@@ -497,6 +503,63 @@ in any specification.

+
+

Custom variablesother

+

CSS variables that contain specific values to be reused throughout a document.

+

HTML

<p class="custom-variables">CSS is awesome!</p>
+
+

CSS

:root {
+  --some-color: #da7800;
+  --some-keyword: italic;
+  --some-size: 1.25em;
+  --some-complex-value: 1px 1px 2px whitesmoke, 0 0 1em slategray, 0 0 0.2em slategray;
+}
+.custom-variables {
+  color: var(--some-color);
+  font-size: var(--some-size);
+  font-style: var(--some-keyword);
+  text-shadow: var(--some-complex-value);
+}
+
+

Demo

+
+
+

CSS is awesome!

+
+
+ +

Explanation

+

The variables are defined globally within the :root CSS pseudo-class which matches the root element of a tree representing the document. Variables can also be scoped to a selector if defined within the block.

+

Declare a variable with --variable-name:.

+

Reuse variables throughout the document using the var(--variable-name) function.

+

Browser support

+
+
+ 88.0% +
+
+

✅ No caveats.

+ + + +

Disable selectioninteractivity

Makes the content unselectable.

@@ -1803,4 +1866,4 @@ var y = e.pageY - btn.offsetTop - btn.offsetParent.offsetTop
- \ No newline at end of file + diff --git a/scripts/build.js b/scripts/build.js index bc9f6f797..cef631b78 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -26,6 +26,10 @@ const TAGS = [ { name: 'interactivity', icon: 'edit-2' + }, + { + name: 'other', + icon: 'tag' } ] diff --git a/snippets/custom-variables.md b/snippets/custom-variables.md index f01324ff6..2313f4ff7 100644 --- a/snippets/custom-variables.md +++ b/snippets/custom-variables.md @@ -2,57 +2,66 @@ CSS variables that contain specific values to be reused throughout a document. +#### HTML + +```html +

CSS is awesome!

+``` + #### CSS ```css :root { - --some-color: #da7800; - --some-keyword: italic; - --some-size: 1.25em; - --some-complex-value: 1px 1px 2px WhiteSmoke, 0 0 1em SlateGray , 0 0 0.2em SlateGray; + --some-color: #da7800; + --some-keyword: italic; + --some-size: 1.25em; + --some-complex-value: 1px 1px 2px whitesmoke, 0 0 1em slategray, 0 0 0.2em slategray; +} + +.custom-variables { + color: var(--some-color); + font-size: var(--some-size); + font-style: var(--some-keyword); + text-shadow: var(--some-complex-value); } ``` #### Demo - -

CSS is awesome!

- - #### Explanation -Declare variable with `--variable-name:`. +The variables are defined globally within the `:root` CSS pseudo-class which matches the root element of a tree representing the document. Variables can also be scoped to a selector if defined within the block. -Reuse declared variable throughout the document using the `var(--variable-name)` function. +Declare a variable with `--variable-name:`. + +Reuse variables throughout the document using the `var(--variable-name)` function. #### Browser support -⚠️ This is an experimental technology. - - +✅ No caveats. * https://caniuse.com/#feat=css-variables + +