✨ Animated Backgrounds = Engaging UI
Static backgrounds are boring. CSS animated backgrounds create engaging, dynamic interfaces.
📝 Animated Backgrounds
// Gradient Animation
@keyframes gradient {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
.animated-gradient {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
background-size: 200% 200%;
animation: gradient 10s ease infinite;
}
// Particle Background
@keyframes float {
0%, 100% { transform: translateY(0) rotate(0deg); }
50% { transform: translateY(-20px) rotate(180deg); }
}
.particle {
position: absolute;
border-radius: 50%;
background: rgba(255,255,255,0.3);
animation: float 5s ease-in-out infinite;
}
// Wave Animation
@keyframes wave {
0% { transform: translateX(0); }
100% { transform: translateX(-50%); }
}
.wave {
background: repeating-linear-gradient(
90deg,
transparent 0px,
rgba(255,255,255,0.1) 50px,
transparent 100px
);
width: 200%;
animation: wave 20s linear infinite;
}
🎯 Advanced Background Effects
// Ripple Effect
@keyframes ripple {
from {
transform: scale(0);
opacity: 1;
}
to {
transform: scale(4);
opacity: 0;
}
}
.ripple {
position: absolute;
border: 2px solid rgba(255,255,255,0.3);
border-radius: 50%;
animation: ripple 2s ease-out;
}
// Shimmer Effect
@keyframes shimmer {
0% { background-position: -200% 0; }
100% { background-position: 200% 0; }
}
.shimmer {
background: linear-gradient(
90deg,
transparent 25%,
rgba(255,255,255,0.2) 50%,
transparent 75%
);
background-size: 200% 100%;
animation: shimmer 2s infinite;
}
// Holographic Background
.holographic {
background: linear-gradient(120deg,
#a8edea 0%,
#fed6e3 50%,
#a8edea 100%);
background-size: 300% 300%;
animation: holographic 6s ease infinite;
}
@keyframes holographic {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
// Matrix Rain
.matrix-bg {
font-family: 'Courier New', monospace;
background: #000;
overflow: hidden;
}
💡 Background Animation Tips
- Keep animations subtle
- Use will-change for performance
- Test on different browsers
- Consider reduced motion preferences
- Use appropriate durations
Animated backgrounds create immersive experiences. They make websites feel alive and engaging.
