CSS Properties for Creating Animations and Smooth Transitions
Main CSS Properties for Animations and Transitions
CSS provides two approaches for creating visual effects:
- Smooth transitions (
transition) — for simple effects (on hover, focus, etc.) - Animations (
@keyframes + animation) — for complex and multi-step effects
Transition — Smooth Transitions
Used for animating property changes when element state changes.
.button {
background: blue;
transition: background 0.3s ease;
}
.button:hover {
background: red;
}
Main Properties:
transition-property— which property to animatetransition-duration— durationtransition-timing-function— easing functiontransition-delay— delay before start
Animation — Complex Animations
For multi-step animations with full control.
@keyframes slideIn {
from {
transform: translateX(-100%);
}
to {
transform: translateX(0);
}
}
.element {
animation: slideIn 1s ease-out;
}
Main Properties:
animation-name— keyframes nameanimation-duration— durationanimation-timing-function— easinganimation-delay— delayanimation-iteration-count— repeat countanimation-direction— direction
Tip:
Use transition for simple effects, animation for complex multi-step animations.