I've been playing around with CSS counters lately and I wondered if it was possible to put them in a CSS animation loop and increment them. My code is fairly simple:
div {
animation-name: anim;
animation-duration: 0.5s;
animation-iteration-count: 10;
animation-fill-mode: forwards;
}
div:before {
counter-increment: variable;
content: counter(variable);
}
@keyframes anim {
100% { counter-increment: variable; }
}
<div></div>
You can see the number goes up, but then it snaps back to 1. I assumed the animation-fill-mode: forwards
would prevent that from happening, but I guess not.
Am I doing something wrong, or is this not possible with CSS counters?