CSS: animation-direction

The animation-direction property chooses whether each cycle runs forward, backward, or alternates direction.

What you will learn

Back-and-forth example

.indicator {
  animation: move 600ms ease-in-out 2 alternate;
}

@keyframes move {
  from { transform: translateX(0); }
  to { transform: translateX(2rem); }
}

alternate runs the first cycle forward and the next backward. reverse starts from the end of the keyframes.

Common mistakes