Maison > interface Web > tutoriel CSS > CSS PIE TIMER REAVISITÉ

CSS PIE TIMER REAVISITÉ

Jennifer Aniston
Libérer: 2025-03-24 09:52:17
original
443 Les gens l'ont consulté

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 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%;
  }
}
Copier après la connexion

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

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal