Autoscoping (#103)
* Add autoscoping with generated demo * Remove manual demo from all snippets * Add JavaScript inside IIFE * Align mouse-cursor-gradient-tracking.md to demo code * Match snippets to demo * Update CONTRIBUTING.md * Create reusable function for code extraction
This commit is contained in:
@ -12,13 +12,14 @@ CSS variables that contain specific values to be reused throughout a document.
|
||||
|
||||
```css
|
||||
:root {
|
||||
/* Place variables within here to use the variables globally. */
|
||||
}
|
||||
|
||||
.custom-variables {
|
||||
--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);
|
||||
@ -28,28 +29,6 @@ CSS variables that contain specific values to be reused throughout a document.
|
||||
|
||||
#### Demo
|
||||
|
||||
<div class="snippet-demo">
|
||||
<div class="snippet-demo__custom-variables">
|
||||
<p>CSS is awesome!</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.snippet-demo__custom-variables {
|
||||
--some-color: #686868;
|
||||
--some-keyword: italic;
|
||||
--some-size: 1.25em;
|
||||
--some-complex-value: 1px 1px 2px whitesmoke, 0 0 1em slategray , 0 0 0.2em slategray;
|
||||
}
|
||||
|
||||
.snippet-demo__custom-variables p {
|
||||
color: var(--some-color);
|
||||
font-size: var(--some-size);
|
||||
font-style: var(--some-keyword);
|
||||
text-shadow: var(--some-complex-value);
|
||||
}
|
||||
</style>
|
||||
|
||||
#### 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.
|
||||
|
||||
Reference in New Issue
Block a user