#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
4 min read
Question 14 of 49easy

How Do CSS Transitions Work?

Understanding smooth property transitions.

What You'll Learn

  • Transition properties
  • Timing functions
  • Multiple transitions

Transition Properties

styles.cssCSS
.element {
  transition-property: background-color;
  transition-duration: 0.3s;
  transition-timing-function: ease;
  transition-delay: 0s;

  /* Shorthand */
  transition: background-color 0.3s ease;
}

.element:hover {
  background-color: blue;
}

Timing Functions

FunctionBehavior
easeSlow start and end
linearConstant speed
ease-inSlow start
ease-outSlow end
ease-in-outSlow start and end
cubic-bezier()Custom curve

Multiple Transitions

styles.cssCSS
.element {
  transition:
    background-color 0.3s ease,
    transform 0.5s ease-out,
    opacity 0.2s linear;
}

/* Or transition all */
.element {
  transition: all 0.3s ease;
}