CSS animation-play-state
Property
The animation-play-state
property in CSS controls whether an animation is running or paused. It allows you to start, stop, or resume an animation dynamically.
1. Syntax
2. Accepted Values
Value | Description |
---|---|
running (default) | The animation is playing normally. |
paused | The animation is stopped at its current frame until it is resumed. |
3. Example – Pausing an Animation on Hover
✅ The animation stops when hovering over the box.
4. Example – Toggle Animation with JavaScript
✅ Clicking a button pauses and resumes the animation dynamically.
5. Best Practices
✔ Use paused
for interactive elements (e.g., pause on hover).
✔ Combine with JavaScript to give users control over animations.
✔ Ensure animations resume properly when using animation-play-state
.