I have an indeterminate progress bar:
<progress max="100"></progress>
I've styled it with a green background with 45-degree stripes:
progress {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border: none;
}
progress:not([value])::-webkit-progress-bar {
background-image:
-webkit-linear-gradient(-45deg, transparent 33%, rgba(0, 0, 0, 0.2) 33%, rgba(0, 0, 0, 0.2) 66%, transparent 66%),
-webkit-linear-gradient(#b3ee3a, #b3ee3a);
background-size: 2.5em 1.25em, 100% 100%, 100% 100%;
background-position: 10%;
animation-name: stripes;
animation-duration: 2s;
animation-iteration-count: infinite;
}
@keyframes stripes {
from {background-position: 0%}
to {background-position: 100%}
}
(Full Example: https://jsfiddle.net/w9x7sm6c/4/)
Unfortunately, the animation doesn't work. The issue seems to stem from a Chrome bug/feature:
https://bugs.chromium.org/p/chromium/issues/detail?id=486195
Closing this as WontFix.
Reason: @keyframes rule name is scoped, so the name specified is only available in the same treescope (i.e. in the same document or shadow root). progress::-webkit-progress-value pierces document-UA shadow root boundary and styles the element, but animation name defined in the document treescope isn't available in UA shadow root, thus the animation doesn't apply.
...
A workaround could be to make your own widget and animate it, which should work all (if CSS animation is implemented) browsers.
It seems to me that the suggested workaround is to just not use <progress>
, which seems like bad advice to me. I'd rather use the correct semantic elements than inventing something that does the same thing.
Is there any workaround I can use for animating this progress bar in its indeterminate state?