
CSS has come a long way from simple color changes and hover effects. With the power of modern CSS, you can create stunning, fluid animations that bring your web interfaces to life—without relying on JavaScript or external libraries.
Use @keyframes to define the steps of your animation. Control properties like transform, opacity, and color at different stages.
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
Combine duration, timing, delay, and iteration count in one line:
.element {
animation: fadeIn 0.6s ease-out forwards;
}
Transformations like scale, rotate, and translate are GPU-accelerated and ensure smooth animations. Combine them with transitions for interactive effects:
.button:hover {
transform: scale(1.05);
transition: transform 0.3s ease-in-out;
}
Stack multiple animations using comma separation to create complex effects like pulsing, sliding, or fading simultaneously.
Use prefers-reduced-motion to respect users' motion preferences:
@media (prefers-reduced-motion: reduce) {
* {
animation: none !important;
transition: none !important;
}
}
By mastering advanced CSS animations, you can elevate your user experience and build visually engaging websites that stand out—while keeping performance and accessibility in check.