CSS Pie Timer Re-Revisited

Kitty reflected on an ancient blog post here on CSS-Tricks on how to make an animated pie timer. The old technique is still clever. The new technique is equally clever and much easier. I particularly like the steps() animation function


The post CSS Pie Timer Re-Revisited appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.


This content originally appeared on CSS-Tricks and was authored by Chris Coyier

Kitty reflected on an ancient blog post here on CSS-Tricks on how to make an animated pie timer. The old technique is still clever. The new technique is equally clever and much easier. I particularly like the steps() animation function that “flips” the “mask” from side-to-side by rotating a pseudo-element half a turn, That’s just good CSS trickery by gosh.


Allow me to do the “CSS Pie Timer Re-Revisted” post a year or two early just to get ahead of things. It’s not a trick anymore — we just use a conic-gradient() and animate the percentage value as a custom property 0% to 100%.

@property --percentage {
  initial-value: 0%;
  inherits: false;
  syntax: '<percentage>';
}

.chart {
  background: conic-gradient(red var(--percentage), white 0);
  animation: timer 4s infinite linear;
}

@keyframes timer {
  to {
    --percentage: 100%;
  }
}

This should work in Chrome (but nothing else) for now:


The post CSS Pie Timer Re-Revisited appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.


This content originally appeared on CSS-Tricks and was authored by Chris Coyier


Print Share Comment Cite Upload Translate Updates
APA

Chris Coyier | Sciencx (2021-05-11T22:00:29+00:00) CSS Pie Timer Re-Revisited. Retrieved from https://www.scien.cx/2021/05/11/css-pie-timer-re-revisited/

MLA
" » CSS Pie Timer Re-Revisited." Chris Coyier | Sciencx - Tuesday May 11, 2021, https://www.scien.cx/2021/05/11/css-pie-timer-re-revisited/
HARVARD
Chris Coyier | Sciencx Tuesday May 11, 2021 » CSS Pie Timer Re-Revisited., viewed ,<https://www.scien.cx/2021/05/11/css-pie-timer-re-revisited/>
VANCOUVER
Chris Coyier | Sciencx - » CSS Pie Timer Re-Revisited. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/11/css-pie-timer-re-revisited/
CHICAGO
" » CSS Pie Timer Re-Revisited." Chris Coyier | Sciencx - Accessed . https://www.scien.cx/2021/05/11/css-pie-timer-re-revisited/
IEEE
" » CSS Pie Timer Re-Revisited." Chris Coyier | Sciencx [Online]. Available: https://www.scien.cx/2021/05/11/css-pie-timer-re-revisited/. [Accessed: ]
rf:citation
» CSS Pie Timer Re-Revisited | Chris Coyier | Sciencx | https://www.scien.cx/2021/05/11/css-pie-timer-re-revisited/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.