Skip to content

176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.

docs: Mesh Gradient Animation (07.02): How it works shows each blob's own keyframes and duration, as the demo has them, and the production note on keeping blobs out of step says so

matin8fdaf44bf08e
diff --git a/animations/07-ambient-background/mesh-gradient/README.md b/animations/07-ambient-background/mesh-gradient/README.md
index 6129c492..5df80697 100644
--- a/animations/07-ambient-background/mesh-gradient/README.md
+++ b/animations/07-ambient-background/mesh-gradient/README.md
@@ -12,39 +12,43 @@ A mesh gradient is a background of a few large circles of color, blurred so thei
- App splash screens and loading states
## How it works
-Each blob is an absolutely-positioned round `<div>` filled with one color and softened with `filter: blur()`. The key is heavy blur — 80px or more — which dissolves the circle's hard edge into a wash of color. CSS keyframes animate each blob on an independent path:
+Each blob is an absolutely-positioned round `<div>` filled with one color and softened with `filter: blur()`. The key is heavy blur — 80px or more — which dissolves the circle's hard edge into a wash of color. Each blob has keyframes of its own, a single move from where it starts to where it ends, played forward and back (`alternate`) over its own share of `--dur`, the Speed setting:
```css
.blob {
position: absolute;
border-radius: 50%;
- filter: blur(80px);
- opacity: 0.75;
- animation: wander 40s ease-in-out infinite alternate;
+ filter: blur(var(--blob-blur));
+ opacity: .75;
+ mix-blend-mode: var(--blend);
}
-.blob-1 {
+.b1 {
width: 60%; height: 60%;
background: #1a3060; /* deep blue */
top: -10%; left: -10%;
- animation-delay: 0s;
+ animation: b1 var(--dur) ease-in-out infinite alternate;
}
-.blob-2 {
+.b2 {
width: 55%; height: 55%;
background: #2e0a50; /* deep purple */
top: 20%; right: -15%;
- animation-delay: -10s;
+ animation: b2 calc(var(--dur) * 1.1) ease-in-out infinite alternate;
}
-@keyframes wander {
- 0% { transform: translate(0, 0) scale(1); }
- 33% { transform: translate(15%, -20%) scale(1.1); }
- 66% { transform: translate(-10%, 15%) scale(0.9); }
- 100% { transform: translate(20%, 10%) scale(1.05); }
+@keyframes b1 {
+ 0% { transform: translate(0, 0) scale(1); }
+ 100% { transform: translate(20%, 15%) scale(1.2); }
+}
+@keyframes b2 {
+ 0% { transform: translate(0, 0) scale(1); }
+ 100% { transform: translate(-15%, 20%) scale(0.85); }
}
```
+The other blobs follow the same pattern at 0.9, 1.2 and 0.8 times `--dur` (40s at Normal). All of them start together, but because no two take the same time, they soon drift out of step and the colors keep meeting in new ways.
+
**CSS blend modes** change the visual mixing of overlapping blobs:
- `normal` — blobs layer on top of each other; later in DOM = on top
- `screen` — adds RGB values, making overlaps brighter and more saturated
@@ -62,7 +66,7 @@ Heavy blur is the costly part on phones, so the demo halves it on small screens:
| Parameter | Default | Effect |
|-----------|---------|--------|
| Blur | Medium | How much the blobs are blurred: light is 50px, medium 80px and heavy 130px; below about 80px the circles show, above it they become a wash. Phones use half |
-| Speed | Normal | How long each blob takes to drift one way: slow is 64s, normal 40s and fast 24s |
+| Speed | Normal | How long a blob takes to drift one way: slow is 64s, normal 40s and fast 24s, and each blob takes 0.8 to 1.2 times that |
| Colors | Cool | The blob colors: cool, warm, sunset, synthwave or earth tones |
| Number of blobs | 4 | Three, four or five blobs; more make a richer mix |
| Blend | Plain | How overlapping blobs mix: plain stacks them (normal blending), lighter brightens the overlap (screen), deeper darkens it and deepens the colors (overlay) |
@@ -72,7 +76,7 @@ Heavy blur is the costly part on phones, so the demo halves it on small screens:
- **Overflow clipping**: blobs extend beyond the container. Always `overflow: hidden` on the parent so blobs don't bleed into the rest of the page.
- **Native CSS mesh gradients**: the CSS Working Group has a `mesh()` function specification in progress that would render true mesh gradients in CSS without the blur trick. It is not yet shipped in any browser.
- **Figma / Sketch "mesh gradient" tools**: design tools generate mesh gradients as images. For web, the blur-div approach produces a similar aesthetic with full animation capability.
-- **`animation-delay` with negative values**: a negative delay (e.g., `-10s`) starts the animation mid-cycle, preventing all blobs from starting at the same position and looking synchronized.
+- **Keep the blobs out of step**: if every blob shares one duration and starts with the others, they all turn around at the same moment and the same mix comes back every cycle. The demo gives each blob its own path and its own duration instead. A negative `animation-delay` (e.g., `-10s`) is another way: it starts an animation mid-cycle, so blobs that share a duration still never line up.
## See also
- [Animated Gradient Background](../animated-gradient-background/) — one gradient that slowly shifts