How it works
This animated gradient background is a large panel filled with a three-color gradient whose colors drift slowly from one side to the other and back. Behind a hero section or a sign-up card it adds life to the page without any images or video.
The panel's background is linear-gradient(Angle, Color 1, Color 2, Color 3) with background-size: 300% 300%, so only a third of the gradient is visible at once. The drift keyframe moves background-position from 0% 50% to 100% 50% at the midpoint and back to 0% 50% at the end. Because the loop returns to its starting point inside the keyframe itself, it repeats with no seam, and ease-in-out slows down at both turning points.
Parameters: Width, Height, Color 1, Color 2, Color 3, Angle, Corner radius, Duration and Easing. Keep it slow: the 8s default is about the fastest that still feels ambient, and 15 to 20s works for full-page backgrounds. Pick colors that are neighbours on the color wheel (orange, purple and cyan are the defaults) and check that your heading text keeps sufficient contrast with every color it will pass over.
Animating background-position repaints the whole area each frame, which adds up on a full-screen hero on low-end phones. For large areas, put the gradient on an oversized pseudo-element and move it with transform instead, and pause the drift under prefers-reduced-motion.
How do I use the animated gradient as a full-page background?
Apply the gradient, background-size and animation to the body or a fixed full-screen element instead of the demo panel, and drop the width, height and radius. Raise Duration to 15 seconds or more so the motion stays in the background. Make sure text above it has a solid or semi-opaque backing if contrast varies.
Can I use more than three colors?
Yes. Add more color stops to the linear-gradient in the copied CSS. With more colors, increase background-size (for example to 400%) so each band keeps a similar width. Repeating the first color at the end of the list makes the color sequence feel circular, though the back-and-forth loop already avoids any jump.
Why does the gradient move back and forth instead of in one direction?
The keyframe goes from 0% to 100% and back to 0% within one cycle. A one-way slide would need the gradient to tile perfectly or it would jump at the end. The there-and-back motion avoids the seam entirely and feels like slow breathing, which suits an ambient background.