CSS Transitions — Smooth Hover Effects Guide
What are CSS Transitions?
CSS transitions animate a change between one visual state and another over time. They make hover effects, focus states, theme changes, and small UI interactions feel much smoother.
Without transitions, the browser jumps instantly from one style to the next. With transitions, the user sees a controlled motion between those states.
Transition Properties
| Property | Purpose |
|---|---|
transition-property | Which CSS property should animate |
transition-duration | How long the animation takes |
transition-timing-function | Speed curve such as ease or linear |
transition-delay | How long to wait before starting |
Practical Examples
.button {
background-color: #2563eb;
color: white;
transform: translateY(0);
transition: background-color 0.25s ease, transform 0.25s ease;
}
.button:hover {
background-color: #1d4ed8;
transform: translateY(-2px);
}
.card {
box-shadow: 0 0 0 rgba(0, 0, 0, 0);
transition: box-shadow 0.3s ease;
}
.card:hover {
box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}Choosing Good Timing
FAQ
Frequently Asked Questions
Key Takeaways
- Transitions animate style changes between states.
- They are commonly used for hover, focus, and interactive UI feedback.
- Duration, timing function, property, and delay control the transition behavior.
- Short, subtle transitions usually feel better than long dramatic ones.
- Opacity and transform are especially effective transition targets.
See Also
Level Up Your Css Skills
Master Css with these hand-picked resources
10,000+ learners
Free forever
Updated 2026
Related CSS Topics