When the user hovers over the div, the width property will change from 100px to 200px over a period of 2 seconds. The
timing function determines how the transition will progress over time. There are a number of different timing functions available, each with its own characteristics. For example, the
ease timing function will cause the transition to start slowly, speed up in the middle, and slow down at the end.
Here is a table of some of the most common timing functions:
Timing function
Description
ease
Starts slowly, speeds up in the middle, and slows down at the end.
ease-in
Starts slowly and speeds up as it progresses.
ease-out
Speeds up at the beginning and slows down as it progresses.
linear
The transition progresses at a constant speed.
drive_spreadsheetExport to Sheets
You can also use the transition-delay property to delay the start of the transition. For example, the following code would create a smooth transition effect for the
width property that takes 2 seconds, but the transition will not start until 1 second after the user hovers over the
div:
The transition-duration property can also be used to specify a different duration for different properties. For example, the following code would create a smooth transition effect for the
width and height properties, but the transition for the
width property would take 2 seconds and the transition for the
height property would take 1 second:
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
To create a smooth transition effect between CSS property changes, you can use the
transitionproperty. Thetransitionproperty takes three values:For example, the following code would create a smooth transition effect for the
widthproperty that takes 2 seconds:Code snippet
When the user hovers over the
div, thewidthproperty will change from 100px to 200px over a period of 2 seconds. Thetiming functiondetermines how the transition will progress over time. There are a number of different timing functions available, each with its own characteristics. For example, theeasetiming function will cause the transition to start slowly, speed up in the middle, and slow down at the end.Here is a table of some of the most common timing functions:
easeease-inease-outlineardrive_spreadsheetExport to Sheets
You can also use the
transition-delayproperty to delay the start of the transition. For example, the following code would create a smooth transition effect for thewidthproperty that takes 2 seconds, but the transition will not start until 1 second after the user hovers over thediv:Code snippet
The
transition-durationproperty can also be used to specify a different duration for different properties. For example, the following code would create a smooth transition effect for thewidthandheightproperties, but the transition for thewidthproperty would take 2 seconds and the transition for theheightproperty would take 1 second:Code snippet
The
transitionproperty is a powerful tool that can be used to create smooth and visually appealing transitions between CSS property changes.