π What Is animation-delay?
The animation-delay property defines how long an animation waits before starting. It allows you to stage animations, create staggering sequences, and control when the motion begins. This is incredibly useful for choreographed UI animations. β¨
π§© Basic Syntax
Syntax
animation-delay: 2s; /* seconds */
animation-delay: 500ms; /* milliseconds */A positive delay waits before starting.
A negative delay jumps into the animation midway. π€―
π§ͺ Example with Keyframes
@keyframes Example
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.box {
animation-name: fadeIn;
animation-duration: 1s;
animation-delay: 1s;
}β The animation will start 1 second after the element loads.
β³ Negative animation-delay
Negative delays allow the animation to begin as if it has already been running.
Negative Delay Example
animation-delay: -0.5s;β If duration = 1s and delay = -0.5s, the animation begins at the halfway point.
π― Multiple Animations (Comma Separated)
Multiple Delays
animation-name: fade, slide;
animation-duration: 1s, 1.2s;
animation-delay: 0s, 0.6s;β First animation starts immediately
β Second starts after 0.6s
πΌοΈ Real-World Examples
1οΈβ£ Staggered List Animation
Stagger Effect
li:nth-child(1) { animation-delay: 0s; }
li:nth-child(2) { animation-delay: 0.2s; }
li:nth-child(3) { animation-delay: 0.4s; }
li:nth-child(4) { animation-delay: 0.6s; }β Great for menus, onboarding steps, or reveal animations.
2οΈβ£ Modal Entrance with Delay
Modal Delay
.backdrop {
animation: fadeIn 0.5s ease;
}
.modal {
animation: scaleUp 0.3s ease 0.2s; /* delay = 0.2s */
}β Backdrop fades in first, modal follows after a short delay.
3οΈβ£ Hero Section Animation
Hero Text
h1 {
animation: slideDown 0.8s ease-out 0.4s;
}
p {
animation: fadeIn 1s ease 0.6s;
}β Smooth staged animation to create emotional impact.
β¨ animation-delay in Shorthand
Shorthand Animation
animation: fadeIn 1.2s ease-out 0.5s forwards;| Shorthand Part | Meaning |
|---|---|
| fadeIn | animation-name |
| 1.2s | animation-duration |
| ease-out | animation-timing-function |
| 0.5s | animation-delay |
| forwards | animation-fill-mode |
π§ Tips for Using animation-delay
- Use delays to create rhythm and pacing π΅
- Negative delays help sync multiple animations
- Avoid long delays β users should not wait unnecessarily
- Keep delays small for micro-interactions (100β300ms)
- Use staggered delays for lists or groups of elements
π Debugging Tips
- Animation wonβt run if animation-duration = 0
- Ensure animation-name is defined correctly
- Use DevTools animation inspector for fine-tuning
- Watch out for multiple animations affecting timing