Roman Komarov
/*
* Not your usual CSS counters
* (three interesting aspects)
*/
.Example > .Warning::before {
content: "Do not use in production" !important;
}
.Example > .Warning::after {
content: "Experiment responsibly" !important;
}
/*
* 1. Rendering the Counters
* (not just the numbers)
*/
content: counter(my-counter, var(--type)) ") ";
--type: decimal--type: lower-greek--type: upper-latin--type: lower-romanol > li::before {
counter-reset: my-counter var(--value);
}
<ol>
<li style=" --value: 2074 ">🙀</li>
<li style=" --value: 199990692 ">🐶</li>
</ol>
/*
* 2. Unusual Inheritance
* (siblings & children)
*/
.foo {
counter-increment: foo 1;
}
.foo::before {
content: "before: " counter(foo);
}
.foo::after {
content: "after: " counter(foo);
}
<div class="foo">
<div class="foo"></div>
<div class="foo">
<div class="foo"></div>
</div>
</div>
<div class="foo">
<div class="foo"></div>
</div>
/*
* 3. Counters and Layout
* (symbols can matter)
*/
content: counter(my-counter);
1
10
100
PUPPER
/*
* Thanks!
* Experiment responsibly.
*
* These slides: kizu.dev/counters
* (with links)
*
*/