
Animations are not about making websites flashy. Good animations guide attention, provide feedback, and make interfaces feel alive.
This complete guide covers CSS transitions and animations from a UI perspective. You will learn hover effects, smooth state changes, keyframes, and how to animate responsibly without hurting performance.
Transitions vs Animations
CSS has two animation systems. They solve different problems.
- Transitions animate between two states (hover, focus, active)
- Animations run through multiple steps using keyframes
Info!
Use transitions for interactions. Use animations for repeated or decorative motion.
1. CSS Transitions (The Basics)
A transition smoothly changes a property when its value changes.
The transition runs only when the background value changes.
2. Transition Properties Explained
A complete transition has four parts:
- property – what animates
- duration – how long it takes
- timing-function – how it moves
- delay – when it starts
Multiple properties can transition together.
3. Performance-Friendly Animations
Not all CSS properties are safe to animate.
- ✅ transform
- ✅ opacity
- ❌ width
- ❌ height
- ❌ top / left
Warning!
Animating layout properties can cause jank and reflows.
4. Hover Effects (Modern UI Pattern)
Hover effects provide instant feedback and depth.
Small scale and elevation changes feel natural.
5. CSS Animations & Keyframes
Animations allow full control over motion using keyframes.
Keyframes define motion stages, not states.
6. Multi-Step Animations
Keyframes can control complex motion.
Scale + opacity creates soft breathing motion.
7. UI Microinteractions
Microinteractions make interfaces feel responsive.
Active states benefit from quick, snappy motion.
8. Animation Timing Functions
Timing defines how motion feels.
- ease – natural
- linear – mechanical
- ease-in – slow start
- ease-out – soft stop
Tip!
Most UI animations should use ease-out.
Common Animation Mistakes
- Over-animating everything
- Long durations
- Animating layout properties
- Ignoring reduced-motion users
Warning!
Motion should help users, not distract them.
Final Tips
- Keep animations subtle
- Use transitions for interactions
- Animate transform and opacity
- Let motion reinforce hierarchy
Good animations are felt, not noticed.
Next lesson: CSS Variables & Custom Properties