0% completed
Looping and pausing animations let you control how long and under what circumstances an animation runs. With looping, you can make an animation repeat indefinitely or a set number of times. With pausing, you can stop an animation from playing temporarily—commonly used on user interaction.
infinite
makes the animation loop endlessly.In this example, a box rotates continuously using an infinite loop.
Explanation:
@keyframes rotate
rule defines an animation that rotates an element from 0° to 360°..rotating-box
element uses animation-iteration-count: infinite
to repeat the rotation forever, creating a smooth, continuous spin.running
(default) and paused
.In this example, a box rotates continuously until the user hovers over it, at which point the animation pauses.
Explanation:
@keyframes spin
rule defines a full rotation animation..spin-box
element continuously rotates using animation: spin 4s linear infinite;
.animation-play-state
is set to paused
, stopping the animation until the pointer leaves the box.By mastering looping and pausing techniques, you can create engaging animations that add depth and interactivity to your web pages—all while keeping control of their behavior and performance.
.....
.....
.....