</> Code Corner

CSS · CSS Advanced · Lesson 49

CSS Transitions

Change property values smoothly.

CSS transitions allow you to change property values smoothly over a given duration.

Example

<style>
.box {
  width: 100px; height: 100px; background: #04AA6D;
  transition: width 0.6s ease-in-out, background-color 0.6s, transform 0.6s;
}
.box:hover { width: 260px; background-color: dodgerblue; transform: rotate(10deg); }
</style>
<div class="box"></div>
<p>Hover over the box.</p>
Property Use
transition-property Which property to animate
transition-duration How long it takes
transition-timing-function ease, linear, ease-in, ease-out, ease-in-out
transition-delay Wait before starting
transition Shorthand

Keep reading “CSS Transitions”

Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.

Chat with us 👋