AI CSS Animations

Screensaver Bounce Loader

A little badge drifts around a screen frame and bounces off every edge, changing hue each time it hits a side wall. Two linear alternate animations with different periods.

Also known as: dvd screensaver animation, bouncing logo loader, corner bounce loader.

HTML

<div class="ldr-screensaver-bounce" role="status" aria-label="Loading">
  <span class="ldr-screensaver-bounce-x"><span class="ldr-screensaver-bounce-badge"></span></span>
</div>

CSS

.ldr-screensaver-bounce {
  --s: var(--ldr-size, 48px);
  --c: var(--ldr-color, #3b82f6);
  position: relative;
  width: calc(var(--s) * 1.9);
  height: calc(var(--s) * 1.1);
  box-sizing: border-box;
  border: calc(var(--s) / 20) solid color-mix(in srgb, var(--ldr-color, #3b82f6) 30%, transparent);
  border-radius: calc(var(--s) / 8);
}
.ldr-screensaver-bounce-x {
  position: absolute;
  top: calc(var(--s) * 0.04);
  left: calc(var(--s) * 0.04);
  animation: ldr-screensaver-bounce-x 1.6s linear infinite alternate;
}
.ldr-screensaver-bounce-badge {
  position: absolute;
  width: calc(var(--s) * 0.44);
  height: calc(var(--s) * 0.26);
  border-radius: 50%;
  background: var(--c);
  animation:
    ldr-screensaver-bounce-y 0.9s linear infinite alternate,
    ldr-screensaver-bounce-hue 6.4s steps(4) infinite;
}
.ldr-screensaver-bounce-badge::after {
  content: "";
  position: absolute;
  inset: 34% 24%;
  border-radius: 50%;
  background: color-mix(in srgb, var(--c) 40%, #fff);
}
@keyframes ldr-screensaver-bounce-x {
  from { transform: translateX(0); }
  to   { transform: translateX(calc(var(--s) * 1.28)); }
}
@keyframes ldr-screensaver-bounce-y {
  from { transform: translateY(0); }
  to   { transform: translateY(calc(var(--s) * 0.66)); }
}
/* One hue step per side-wall hit, since the x trip takes exactly 1.6s. */
@keyframes ldr-screensaver-bounce-hue {
  from { filter: hue-rotate(0deg); }
  to   { filter: hue-rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .ldr-screensaver-bounce, .ldr-screensaver-bounce *, .ldr-screensaver-bounce::before, .ldr-screensaver-bounce::after, .ldr-screensaver-bounce *::before, .ldr-screensaver-bounce *::after {
    animation-duration: 3s;
  }
}

Customizing this loader

  • Color: set --ldr-color on the element or a parent. Currently previewing #3b82f6.
  • Size: set --ldr-size. Every dimension in the snippet is derived from it. Currently previewing 64px.
  • Speed: change the duration on the animation shorthand. Delays on the children are relative, so they keep their rhythm.
  • Accessibility: the root carries role="status" and an aria-label so screen readers announce the wait. The reduced-motion rule at the end slows the animation for users who asked for less motion.

Similar loaders