AI CSS Animations

Ripple Background

Soft rings spread from the center and fade one after another, like ripples on still water. Five layers share one keyframe with staggered delays, and only transform and opacity animate.

Also known as: radial ripple background, water ripple effect css, concentric circles animation.

HTML

<div class="bgx-radial-ripple" aria-hidden="true">
  <span></span><span></span><span></span><span></span><span></span>
</div>

CSS

.bgx-radial-ripple {
  --c: var(--bgx-color, #3b82f6);
  font-size: var(--bgx-size, 16px);
  position: absolute;
  inset: 0;
  overflow: hidden;
  --t: 6s;
  container-type: size;
  background: radial-gradient(circle, color-mix(in srgb, var(--c) 14%, #fff), color-mix(in srgb, var(--c) 5%, #fbfcfe) 70%);
}
.bgx-radial-ripple span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120cqmax;
  height: 120cqmax;
  margin: -60cqmax 0 0 -60cqmax;
  border-radius: 50%;
  background: radial-gradient(closest-side, transparent 86%, color-mix(in srgb, var(--c) 22%, transparent) 93%, color-mix(in srgb, var(--c) 60%, transparent) 97%, transparent 99%);
  transform: scale(var(--at));
  opacity: calc(1 - var(--at));
  animation: bgx-radial-ripple-spread var(--t) linear calc(var(--t) * var(--at) * -1) infinite;
}
.bgx-radial-ripple span:nth-child(1) { --at: 0.1; }
.bgx-radial-ripple span:nth-child(2) { --at: 0.3; }
.bgx-radial-ripple span:nth-child(3) { --at: 0.5; }
.bgx-radial-ripple span:nth-child(4) { --at: 0.7; }
.bgx-radial-ripple span:nth-child(5) { --at: 0.9; }
@keyframes bgx-radial-ripple-spread {
  0%   { transform: scale(0.02); opacity: 0; }
  8%   { opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .bgx-radial-ripple, .bgx-radial-ripple *, .bgx-radial-ripple::before, .bgx-radial-ripple::after, .bgx-radial-ripple *::before, .bgx-radial-ripple *::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