CSS Animated Mesh Gradient
Four soft radial color blobs that drift slowly across the background in opposite directions.
<div class="mesh-animated"></div>
.mesh-animated {
background-color: #fdf2f8;
background-image:
radial-gradient(circle, #f472b6, #0000 30%),
radial-gradient(circle, #60a5fa, #0000 30%),
radial-gradient(circle, #a78bfa, #0000 30%),
radial-gradient(circle, #34d399, #0000 30%);
background-size: 200% 200%;
animation: mesh-animated-drift 16s ease-in-out infinite alternate;
}
@keyframes mesh-animated-drift {
0% { background-position: 0 0, 100% 0, 100% 100%, 0 100%; }
50% { background-position: 60% 20%, 30% 70%, 20% 40%, 80% 60%; }
100% { background-position: 100% 100%, 0 100%, 0 0, 100% 0; }
}
@media (prefers-reduced-motion: reduce) {
.mesh-animated {
animation: none;
background-position: 30% 30%, 70% 30%, 70% 70%, 30% 70%;
}
}
About this CSS Animated Mesh Gradient
This CSS Animated Mesh Gradient is 23 lines of pure CSS (0.7 KB) with no JavaScript and no dependencies. It uses keyframe animations, radial gradients and reduced-motion support. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.
CSS features used
Customize it
The colors in this snippet. Search and replace them to match your brand:
#fdf2f8#f472b6#0000#60a5fa#a78bfa#34d399
How to use this animated mesh gradient
- Copy the HTML and paste it where you want the element to appear.
- Copy the CSS into your stylesheet, or inside a
<style>tag. - Keep the
.mesh-animatedclass name, or rename it in both places. Then tweak colors, sizes and timing to match your design. - Using React or Next.js? Change
classtoclassNamein the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).
Building with an AI tool?
“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.