Learn how to create smooth, engaging animations and transitions using CSS
Property | Description | Example Values |
---|---|---|
transition-property | Specifies which CSS properties should be animated | all , opacity , transform , width, height |
transition-duration | Defines how long the transition takes to complete | 0.3s , 300ms , 2s |
transition-timing-function | Specifies the speed curve of the transition | ease , linear , ease-in , ease-out , ease-in-out , cubic-bezier(0.1, 0.7, 1.0, 0.1) |
transition-delay | Defines when the transition will start | 0s , 0.5s , 500ms |
transition (shorthand) | Combines all transition properties into one declaration | all 0.3s ease 0s , opacity 0.5s linear |
Layout Properties
width
, height
margin
, padding
top
, right
, bottom
, left
border-width
transform
when possible.Visual Properties
opacity
color
, background-color
box-shadow
, text-shadow
border-color
, outline-color
visibility
Transform Properties
transform: translate()
transform: scale()
transform: rotate()
transform: skew()
Filter Properties
filter: blur()
filter: brightness()
filter: contrast()
filter: grayscale()
filter: hue-rotate()
filter: invert()
filter: opacity()
filter: saturate()
filter: sepia()
Property | Description | Example Values |
---|---|---|
animation-name | Specifies the name of the @keyframes rule | slide-in , fade-out , pulse |
animation-duration | Defines how long the animation takes to complete one cycle | 1s , 500ms , 2.5s |
animation-timing-function | Specifies the speed curve of the animation | ease , linear , ease-in , ease-out , ease-in-out , cubic-bezier(0.1, 0.7, 1.0, 0.1) |
animation-delay | Defines when the animation will start | 0s , 1s , -0.5s (negative values start the animation partway through) |
animation-iteration-count | Specifies how many times the animation should run | 1 , 3 , infinite |
animation-direction | Defines whether the animation should play forward, backward, or alternate | normal , reverse , alternate , alternate-reverse |
animation-fill-mode | Specifies what values are applied before/after the animation | none , forwards , backwards , both |
animation-play-state | Specifies whether the animation is running or paused | running , paused |
animation (shorthand) | Combines all animation properties into one declaration | slide-in 1s ease-out 0s 1 normal forwards |
animation-fill-mode
property determines what happens before the animation starts and after it ends.
Value | Before Animation | After Animation |
---|---|---|
none (default) | Element displays in its normal state | Element returns to its normal state |
forwards | Element displays in its normal state | Element retains the computed values set by the last keyframe |
backwards | Element displays the computed values set by the first keyframe | Element returns to its normal state |
both | Element displays the computed values set by the first keyframe | Element retains the computed values set by the last keyframe |
offset-path
(part of the Motion Path Module), you can animate elements along a defined path.
transform
opacity
filter
will-change
or transform: translateZ(0)
.
will-change
sparingly and only for elements that will actually change. Overuse can cause memory issues.contain: paint
to isolate their paint areas.
width
, height
top
, right
, bottom
, left
margin
, padding
font-size
position
transform
equivalents:
prefers-reduced-motion
media query allows you to provide alternative animations or disable them based on user system preferences.
transform
and opacity
for better performanceprefers-reduced-motion
and animation controls