Category: html_css
CSS transitions
Published on 29 Jun 2026
Explanation
CSS transitions create smooth animations when a property changes, improving user interaction.
Code:
.button {
transition: all 0.3s ease;
}
Explanation
Transitions are commonly used with the :hover pseudo-class to animate property changes.
Code:
.button:hover {
background: blue;
}
Explanation
You can animate specific properties such as color, width, or transform instead of all properties.
Code:
.card {
transition: transform 0.5s;
}
Explanation
The transform property works well with transitions to create scaling and rotation effects.
Code:
.card:hover {
transform: scale(1.1);
}
Explanation
Transition timing functions like ease, linear, ease-in, and ease-out control the animation speed.
Code:
.box {
transition: opacity 0.5s ease-in-out;
}