HTML Academy
Transition duration, step 2
Smooth transitions3/29
Back to the list of tasks
  • 1. The transition-duration property
  • 2. Transition duration, step 2
  • 3. The transition-property: which properties can be changed smoothly?
  • 4. The transition-delay property
  • 5. The “form” of the transition, transition-timing-function
  • 6. transition-timing-function, step 2
  • 7. transition-timing-function, step 3
  • 8. transition-timing-function, step 4
  • 9. Paper buttons, step 1
  • 10. Paper buttons, step 2
  • 11. Paper buttons, step 3
  • 12. Checkboxes, step 1
  • 13. Checkboxes, step 2
  • 14. Checkboxes, step 3
  • 15. Radio buttons, step 1
  • 16. Radio buttons, step 2
  • 17. Radio buttons, step 3
  • 18. Toggle switches, step 1
  • 19. Toggle switches, step 2
  • 20. Toggle switches, step 3
  • 21. Toggle switches, step 4
  • 22. The transformer icon, step 1
  • 23. The transformer icon, step 2
  • 24. The transformer icon, step 3
  • 25. The transformer icon, step 4
  • 26. Text input field, step 1
  • 27. Text input field, step 2
  • 28. Text input field, step 3
  • 29. Text input field, step 4
The transition-delay property
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

The transition-property: which properties can be changed smoothly?

By default, the smooth transition affects all animated element properties. This behavior corresponds to the value all of the transition-property property, and this is the default value.

This behavior is often undesirable, especially when there are many properties in the rule.

You can specify which properties should change smoothly by listing them in the transition-property separated by commas:

transition-property: width;     // Smoothly changes only the width.
transition-property: width, height; // Smoothly changes the width and height.

You can also specify that various properties have different durations for transitions. The values are separated by a comma:

transition-property: width, height;
transition-duration: 1s, 5s; // The width changes for 1 second, and the height changes for 5 seconds.

Let’s try to apply the described property in practice. In this example, the background-color, transform, and font-size properties for the button are animated.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <title>The transition-property: which properties can be changed smoothly?</title> <meta charset="utf-8"> <link rel="stylesheet" href="material.css"> <link rel="stylesheet" href="style.css"> </head> <body class="theory-theme"> <button class="btn" type="button">&#58880;</button> </body> </html>
CSS
.btn { background-color: #00e676; color: #ffffff; transition-duration: 1s; transition-property: all; } .btn-active { background-color: #ff5252; font-size: 60px; transform: rotate(180deg); }

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
    1. For the .btn button, assign a smooth transition only for the background-color property,
    2. then assign a smooth transition only for the transform property,
    3. and finally assign background-color, transform for both properties at the same time.
    4. Change the duration of the transition for .btn to 1s, 3s.

    Click the .btn button in the mini-browser to switch its btn-active class and see a smooth transition.

    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.