HTML Academy
Previous task
Animations1/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
@keyframes: storyboard
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Hello, animation!

CSS enables you to create complex animations and control them in a number of ways. A description of a CSS animation consists of two parts: a set of @keyframes and animation parameters.

Here is a sample description of the keyframes of an animation:

@keyframes stretching {
  0% {
    width: 100px;
  }
  100% {
    width: 200px;
  }
}

The animation in this example is called stretching and describes how a block’s style will change from the initial to the final point. This animation can be applied to any element. All you need to do is to add two properties to your CSS: animation-name (name of your animation) and animation-duration (duration) and define the corresponding values. For example:

.button {
  animation-name: stretching;
  animation-duration: 1s;
}

This code will assign the stretching animation to all elements of the button class. As a result, the element will be gradually stretched horizontally from 100px to 200px in 1s.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <title>Hello, animation!</title> <meta charset="utf-8"> <link rel="stylesheet" href="epoch1.css"> <link rel="stylesheet" href="style.css"> </head> <body class="ancient"> <div class="stone"> <div class="wood-wheel"></div> </div> </body> </html>
CSS
/* @keyframes rotate { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } */ /* .wood-wheel { animation-name: rotate; animation-duration: 2s; } */

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

    Uncomment in CSS:

    1. description of the keyframes of the @keyframes rotate animation;
    2. rule for the .wood-wheel class.

    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.