Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Managing Animation State | Animations
course content

Contenido del Curso

Advanced CSS Techniques

Managing Animation StateManaging Animation State

animation-fill-mode property

We can control the element styles before and after the animation run. animation-fill-mode specifies whether an element should retain its final state from the animation or revert to its original state.

  • none - This is the default value. The animation won't affect the element view before or after the animation. The element will look the same as initially;
  • forwards - It means that the styles at the end of the animation will remain for the element, and it won't return to its initial view;
  • backwards - It means that the element will have the styles specified at the beginning of the animation. Even if the animation is triggered on hover or it has some delay;
  • both - It combines backwards and forwards. It means that before the animation run, the element will have the styles specified at the animation start. After the animation run, the element will have the styles set at the animation end.

Let's consider the following example to check the difference between the values. It was made to show that the element state will never change if we have applied the animation-fill-mode with the correct value. After running the code, the final state of the elements will be unchangeable. If we need to see the animation again, please reload the page.

html

index.html

css

index.css

js

index.js

animation-play-state property

We can control the animation play state. It can be paused or running.

  • running - This is the default value. It starts or resumes the animation;
  • paused - It stops the animation at the current state.

Let's consider the following example, where we will stop the infinite animation on the cursor hover.

html

index.html

css

index.css

js

index.js

What is the purpose of the animation-fill-mode property

Selecciona la respuesta correcta

¿Todo estuvo claro?

Sección 4. Capítulo 4
course content

Contenido del Curso

Advanced CSS Techniques

Managing Animation StateManaging Animation State

animation-fill-mode property

We can control the element styles before and after the animation run. animation-fill-mode specifies whether an element should retain its final state from the animation or revert to its original state.

  • none - This is the default value. The animation won't affect the element view before or after the animation. The element will look the same as initially;
  • forwards - It means that the styles at the end of the animation will remain for the element, and it won't return to its initial view;
  • backwards - It means that the element will have the styles specified at the beginning of the animation. Even if the animation is triggered on hover or it has some delay;
  • both - It combines backwards and forwards. It means that before the animation run, the element will have the styles specified at the animation start. After the animation run, the element will have the styles set at the animation end.

Let's consider the following example to check the difference between the values. It was made to show that the element state will never change if we have applied the animation-fill-mode with the correct value. After running the code, the final state of the elements will be unchangeable. If we need to see the animation again, please reload the page.

html

index.html

css

index.css

js

index.js

animation-play-state property

We can control the animation play state. It can be paused or running.

  • running - This is the default value. It starts or resumes the animation;
  • paused - It stops the animation at the current state.

Let's consider the following example, where we will stop the infinite animation on the cursor hover.

html

index.html

css

index.css

js

index.js

What is the purpose of the animation-fill-mode property

Selecciona la respuesta correcta

¿Todo estuvo claro?

Sección 4. Capítulo 4
some-alt