CSS Animations allow elements to smoothly change styles over time without requiring JavaScript. They can be used for effects like fading, sliding, bouncing, spinning, and more.
CSS animations create smooth transitions between styles by defining keyframes. A keyframe represents a stage of an animation, specifying how an element should look at a certain point in time.
To create an animation, we need:
@keyframes
→ Defines the animation sequence.
Property | Description | Example |
---|---|---|
animation-name |
Specifies the name of the animation | animation-name: fadeIn; |
animation-duration |
Sets how long the animation runs | animation-duration: 3s; |
animation-timing-function |
Defines speed changes | ease, linear, ease-in, ease-out, ease-in-out |
animation-delay |
Sets a delay before animation starts | animation-delay: 1s; |
animation-iteration-count |
Number of times animation runs | 1, 2, infinite |
animation-direction |
Determines animation flow | normal, reverse, alternate |
animation-fill-mode |
Controls how elements look before/after animation | none, forwards, backwards, both |
animation-play-state |
Starts or pauses the animation | running, paused |