liveBook · Manning

Animation-iteration-count

As explained in Tiny CSS Projects

The CSS animation-iteration-count property specifies the number of times an animation cycle runs.

The animation-iteration-count property sets how many times an animation cycle runs. Its default value is 1, so an animation normally plays once and stops. section 3.4 section 3.4.3

Use the infinite keyword to keep an animation playing continuously, or use an integer to run it a specific number of times. section 3.4.3

Repeating a loading animation

A loader can apply the same doScale keyframes to several rectangles. With animation-iteration-count: infinite, each rectangle continues shrinking and growing instead of stopping after one cycle. section 3.4 section 3.4.3

Listing 3.9 Added animation iteration count
rect {
  animation-name: doScale;
  animation-duration: 2.2s;
  animation-iteration-count: infinite;
}

This listing shows animation-iteration-count alongside the keyframe name and duration in a complete rectangle animation rule. section 3.4.3

The property fits into broader CSS animation declarations:

  • Combine the name, duration, and iteration count with the animation shorthand, such as animation: doScale 2.2s infinite. section 3.4.4
  • Pair repetition with animation-delay values to stagger otherwise identical elements and create a ripple effect. section 3.4

How Tiny CSS Projects covers it

How deep it goes
Defines the default, integer, and infinite values, then applies them in a loader without exploring animation timing internals.
Examples
Demonstrates repeated doScale keyframes on shrinking and growing loader rectangles, including an infinite value and a finite count of 10.
What it assumes
Assumes basic CSS rules and introduces repetition alongside keyframes, animation names, and durations.
What you can do after
Apply repetition through a standalone declaration or the animation shorthand in a CSS loading animation.
How it connects
Connects CSS animations with keyframes, animation-duration, animation-delay, animation shorthand, and transform.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Tiny CSS Projects. The section links point to the parts of the book it draws on.