AI CSS Animations

Liquid Wallpaper Background

Rich color pools slowly fold into each other like a modern desktop wallpaper, with a soft highlight gliding through. Three blurred conic gradients turn at different speeds around off-center points.

Also known as: moving gradient background css, animated gradient background, macos wallpaper gradient css, fluid gradient background.

HTML

<div class="bgx-liquid-wallpaper" aria-hidden="true"><span></span><span></span><span></span></div>

CSS

.bgx-liquid-wallpaper {
  --c: var(--bgx-color, #3b82f6);
  font-size: var(--bgx-size, 16px);
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: oklch(from var(--c) 0.42 0.16 calc(h - 10));
  isolation: isolate;}
.bgx-liquid-wallpaper span {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: max(130%, 36em);
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  filter: blur(2.5em);
  animation: bgx-liquid-wallpaper-turn var(--t) linear infinite var(--dir, normal);
}
.bgx-liquid-wallpaper span:nth-child(1) {
  --x: 20%; --y: 10%; --t: 28s;
  background: conic-gradient(oklch(from var(--c) 0.72 0.17 calc(h + 0)), oklch(from var(--c) 0.55 0.2 calc(h + 50)), oklch(from var(--c) 0.82 0.12 calc(h - 70)), oklch(from var(--c) 0.6 0.18 calc(h - 20)), oklch(from var(--c) 0.72 0.17 calc(h + 0)));
}
.bgx-liquid-wallpaper span:nth-child(2) {
  --x: 85%; --y: 90%; --t: 34s; --dir: reverse;
  width: max(100%, 28em);
  background: conic-gradient(oklch(from var(--c) 0.5 0.2 calc(h + 80)), transparent 30%, oklch(from var(--c) 0.78 0.14 calc(h + 130)), transparent 70%, oklch(from var(--c) 0.5 0.2 calc(h + 80)));
  mix-blend-mode: hard-light;
}
.bgx-liquid-wallpaper span:nth-child(3) {
  --x: 55%; --y: 45%; --t: 20s;
  width: max(70%, 20em);
  background: conic-gradient(from 90deg, rgb(255 255 255 / 0.5), transparent 25%, transparent 50%, rgb(255 255 255 / 0.35) 75%, transparent);
  mix-blend-mode: soft-light;
}
@keyframes bgx-liquid-wallpaper-turn {
  to { rotate: 360deg; }
}
@media (prefers-reduced-motion: reduce) {
  .bgx-liquid-wallpaper, .bgx-liquid-wallpaper::before, .bgx-liquid-wallpaper::after, .bgx-liquid-wallpaper *, .bgx-liquid-wallpaper *::before, .bgx-liquid-wallpaper *::after { animation-play-state: paused; }
}

@media (prefers-reduced-motion: reduce) {
  .bgx-liquid-wallpaper, .bgx-liquid-wallpaper *, .bgx-liquid-wallpaper::before, .bgx-liquid-wallpaper::after, .bgx-liquid-wallpaper *::before, .bgx-liquid-wallpaper *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --bgx-color on the element or a parent. Currently previewing #3b82f6.
  • Pattern scale: set --bgx-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar animated backgrounds