The Background-Size Animation Technique
CSS gradient animations use a clever technique: create a gradient larger than the element using background-size: 200% 200%, then animate the background-position with @keyframes. The oversized gradient scrolls behind the element, creating a smooth flowing effect at 60fps.
Three Animation Modes
The Shift animation slides the gradient across the element — best for hero sections and backgrounds. Hue Rotate cycles the gradient through all colors using filter: hue-rotate() — ideal for loading states. Pulse fades the gradient opacity — subtle enough for buttons and cards.
Performance Considerations
Modern browsers GPU-accelerate CSS animations, so performance is generally excellent. Use will-change: background-position as a hint. Longer durations (6-10s) feel more elegant. Consider the prefers-reduced-motion media query to respect user preferences.