Infinite rainbow

FEATURED

In this example below you will see how to do a Infinite rainbow with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by Louis Hoebregts, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright Louis Hoebregts ©
  • HTML
  • CSS
  • JavaScript
    <div class="background">
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
</div>

/*Downloaded from https://www.codeseek.co/Mamboleoo/infinite-rainbow-NMopxm */
    body {
  margin: 0;
  overflow: hidden;
}

.background {
  width: 100vw;
  height: 100vh;
  background: #000000;
}

$animationDuration: 4s;
$amount: 100;
$particleSize: 3vmin;
.background span {
  width: $particleSize;
  height: $particleSize;
  border-radius: $particleSize;
  position: absolute;
  animation-name: move;
  animation-duration: $animationDuration;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  top: 50%;
  left: 50%;

  @for $i from 1 through $amount {
    &:nth-child(#{$i}) {
      $ratio: $i / $amount;
      animation-delay: ($ratio * 0.5) *  $animationDuration;
      $offset: if($i % 2 == 0, 30vmin, -30vmin);
      transform-origin: $offset 0px;
      background: hsl($ratio * 360deg, 70%, 50%);
    }
  }
}

@keyframes move {
  1% {
    z-index: 100;
  }
  60%,
  100% {
    z-index: 0;
    transform: rotate(360deg);
  }
}


/*Downloaded from https://www.codeseek.co/Mamboleoo/infinite-rainbow-NMopxm */
    

Comments