Bouncing Loader


I built this originally (see Codepen demo) in 2018 when I was first starting on the web. It’s a simple relic that continues to stand the test of time.


Code snippet

Just a bunch of divs…

<div class="bouncing-loader">
  <div></div>
  <div></div>
  <div></div>
</div>

…whose movements are controlled by a CSS animation that translates the individual dots up and down, with their opacity fading in and out.

@keyframes bouncing-loader {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
  50% {
    opacity: 0.1;
    transform: translate3d(0, -1rem, 0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.bouncing-loader {
  --dot-size: 1rem;
  display: flex;
  justify-content: space-between;
  gap: var(--dot-size);

  > div {
    width: var(--dot-size);
    height: var(--dot-size);
    background: #ff6d00;
    border-radius: 50%;
    animation: bouncing-loader 1s infinite;
  }

  > div:nth-child(2) {
    animation-delay: 0.2s;
  }

  > div:nth-child(3) {
    animation-delay: 0.4s;
  }
}