HTML Academy
Pre- and post-animation state: animation-fill-mode, step 4
Animations19/31
Back to the list of tasks
  • 1. Hello, animation!
  • 2. @keyframes: storyboard
  • 3. @keyframes: from and to
  • 4. @keyframes: frame grouping
  • 5. Complex animation, step 1
  • 6. Complex animation, step 2
  • 7. Water adventure
  • 8. Animation play count: animation-iteration-count
  • 9. Animation direction: animation-direction, step 1
  • 10. Animation direction: animation-direction, step 2
  • 11. Animation delay: animation-delay, step 1
  • 12. Animation delay: animation-delay, step 2
  • 13. Animation delay: animation-delay, step 3
  • 14. Air journey
  • 15. Pre- and post-animation state: animation-fill-mode, step 1
  • 16. Pre- and post-animation state: animation-fill-mode, step 2
  • 17. Pre- and post-animation state: animation-fill-mode, step 3
  • 18. Pre- and post-animation state: animation-fill-mode, step 4
  • 19. Pre- and post-animation state: animation-fill-mode, step 5
  • 20. Launching a factory, step 1
  • 21. Launching a factory, step 2
  • 22. Stopping and starting an animation: animation-play-state
  • 23. Animation form, animation-timing-function
  • 24. Animation-timing-function, step 2
  • 25. Animation-timing-function, step 3
  • 26. Animation-timing-function, step 4
  • 27. Rocket to the launch pad, step 1
  • 28. Rocket to the launch pad, step 2
  • 29. Landing, step 1
  • 30. Landing, step 2
  • 31. Landing, step 3
Launching a factory, step 1
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Pre- and post-animation state: animation-fill-mode, step 5

The third value of the animation-fill-mode property is both.

It combines the effects of forwards and backwards. That is, before the animation starts, the element gets the state of the first keyframe. When the animation is over, the final state of the animation is preserved.

The animation-fill-mode: both action affects both repeated and alternating animation.

Let’s conduct our final experiment!

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <title>Pre- and post-animation state: animation-fill-mode, step 5</title> <meta charset="utf-8"> <link rel="stylesheet" href="epoch3.css"> <link rel="stylesheet" href="style.css"> </head> <body class="scientific"> <div class="battery"> <span class="energy-logo"></span> <span class="energy-fill"></span> </div> <div class="battery"> <span class="energy-logo"></span> <span class="energy-fill mega-energy-fill"></span> </div> </body> </html>
CSS
.energy-logo { animation-name: vibrate; animation-duration: 2s; } .energy-fill { animation-name: power; animation-duration: 2s; animation-delay: 2s; } @keyframes vibrate { 50% { transform: scale(1.2); } } @keyframes power { 0% { width: 150px; background-color: #01ff70; } 50% { background-color: #ffdc00; } 100% { width: 30px; background-color: #ff4136; } }

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

The code has changed, click “Refresh” or turn autorun on.

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Goalscompleted
0

    Set the following properties to the charge of the experimental .mega-energy-fill battery:

    1. keep the pre- and post-animation states
    2. number of animation cycles: 2,
    3. and then an alternating direction of animation.

    Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2025

    VISAMastercard

    Log in

    or

    Forgot your password?

    Sign up

    Sign up

    or
    Log in

    Restore access

    Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

    Forgot to connect your email to the profile? Email us and we’ll help.