Loading course content...
Loading course content...
Code Playground is only enabled on larger screen sizes.
The animation-direction property defines in which direction the animation will be played, and it accepts four different options:
normal: The animation is played forward.reverse: The animation is played backward.alternate: The animation is played forward first, then backward. This only works when animation-iteration-count is more than 1.alternate-reverse: The animation is played backward first, then forward.div {
/* . . . */
animation-name: change-bg-color;
animation-duration: 4s;
animation-timing-function: ease-in-out;
animation-delay: 2s;
animation-iteration-count: 4;
animation-direction: alternate;
}Animation: direction
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" href="/styles.css"> </head> <body> <div class="two-kf-animation">2 Keyframes Animation</div> <div class="four-kf-animation">4 Keyframes Animation</div> </body> </html>