Pure CSS Columns Loader

Pure CSS Columns Loader

HTML

<div class="container">
      <div class="loader">
        <div class="columnWrapper">
          <div class="column">
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
          </div>
        </div>
        <div class="columnWrapper">
          <div class="column">
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
          </div>
        </div>
        <div class="columnWrapper">
          <div class="column">
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
          </div>
        </div>
        <div class="columnWrapper">
          <div class="column">
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
          </div>
        </div>
        <div class="columnWrapper">
          <div class="column">
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
          </div>
        </div>
        <div class="columnWrapper">
          <div class="column">
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
          </div>
        </div>
        <div class="columnWrapper">
          <div class="column">
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
          </div>
        </div>
        <div class="columnWrapper">
          <div class="column">
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
          </div>
        </div>
        <div class="columnWrapper">
          <div class="column">
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
          </div>
        </div>
        <div class="columnWrapper">
          <div class="column">
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
          </div>
        </div>
        <div class="columnWrapper">
          <div class="column">
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
          </div>
        </div>
        <div class="columnWrapper">
          <div class="column">
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
          </div>
        </div>
        <div class="columnWrapper">
          <div class="column">
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
          </div>
        </div>
        <div class="columnWrapper">
          <div class="column">
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
          </div>
        </div>
        <div class="columnWrapper">
          <div class="column">
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
          </div>
        </div>
        <div class="columnWrapper">
          <div class="column">
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
            <div class="side"></div>
          </div>
        </div>
      </div>
    </div>

SCSS

@function rem($value) {
  @return unquote(($value/1px)/16+"rem");
}

.container {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}
* {
  box-sizing: border-box;
}

@mixin column($height, $width) {
  height: $width;
  width: $width;
  transform-style: preserve-3d;
  .side {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    height: $height;
    width: $width;
    &:nth-child(1) {
      transform: translateZ(-$height / 2);
      height: $width;
    }
    &:nth-child(2) {
      transform: translateZ($height / 2);
      height: $width;
    }
    &:nth-child(3) {
      transform: rotateX(90deg) translateZ($width / 2);
    }
    &:nth-child(4) {
      transform: rotateX(90deg) translateZ(-$width / 2);
    }
    &:nth-child(5) {
      transform: rotateX(90deg) rotateY(90deg) translateZ($width / 2);
    }
    &:nth-child(6) {
      transform: rotateX(90deg) rotateY(-90deg) translateZ($width / 2);
    }
  }
}

$columnCount: 16;
$speed: 4s;
$columnHeight: 200px;
$columnwidth: 50px;
$background: #2c153d;
$color: #2c153d;
$darkenColor: lighten($color, 70%);
body {
  background-color: $background;
}
.loader {
  position: absolute;
  height: rem(350px);
  width: rem(350px);
  transform-style: preserve-3d;
  transform: rotate(0deg) rotateX(60deg) rotate(45deg);
  animation: loaderAnimate $speed * 4 linear infinite;
  .columnWrapper {
    position: absolute;
    transform-style: preserve-3d;
    transform: translateZ(50px);
    &:nth-child(1) {
      left: 0;
      top: 0;
      transform: translate(0, 0);
    }
    &:nth-child(2) {
      left: 25%;
      top: 0;
      transform: translate(-25%, 0);
    }
    &:nth-child(3) {
      left: 50%;
      top: 0;
      transform: translate(-50%, 0);
    }
    &:nth-child(4) {
      left: 75%;
      top: 0%;
      transform: translate(-75%, 0%);
    }
    &:nth-child(5) {
      left: 100%;
      top: 0%;
      transform: translate(-100%, 0%);
    }
    &:nth-child(6) {
      left: 100%;
      top: 25%;
      transform: translate(-100%, -25%);
    }
    &:nth-child(7) {
      left: 100%;
      top: 50%;
      transform: translate(-100%, -50%);
    }
    &:nth-child(8) {
      left: 100%;
      top: 75%;
      transform: translate(-100%, -75%);
    }
    &:nth-child(9) {
      left: 100%;
      top: 100%;
      transform: translate(-100%, -100%);
    }
    &:nth-child(10) {
      left: 75%;
      top: 100%;
      transform: translate(-75%, -100%);
    }
    &:nth-child(11) {
      left: 50%;
      top: 100%;
      transform: translate(-50%, -100%);
    }
    &:nth-child(12) {
      left: 25%;
      top: 100%;
      transform: translate(-25%, -100%);
    }
    &:nth-child(13) {
      left: 0%;
      top: 100%;
      transform: translate(0%, -100%);
    }
    &:nth-child(14) {
      left: 0%;
      top: 75%;
      transform: translate(0%, -75%);
    }
    &:nth-child(15) {
      left: 0%;
      top: 50%;
      transform: translate(0%, -50%);
    }
    &:nth-child(16) {
      left: 0%;
      top: 25%;
      transform: translate(0%, -25%);
    }

    @for $i from 1 through $columnCount {
      &:nth-child(#{$i}) {
        .column {
          animation-delay: #{$i * $speed / $columnCount};
        }
      }
    }

    .column {
      @include column(200px, 60px);
      transform: translateZ(50px);
      animation: columnAnimate $speed ease forwards infinite;

      .side:nth-child(2) {
        background-color: $darkenColor;
      }
      .side:nth-child(3),
      .side:nth-child(4),
      .side:nth-child(5),
      .side:nth-child(6) {
        background-image: linear-gradient(
          0deg,
          $darkenColor,
          $color 100%,
          transparent 100%
        );
      }
    }
  }
}
@keyframes columnAnimate {
  0%,
  60%,
  100% {
    transform: translateZ(50px);
  }
  40% {
    transform: translateZ(-50px);
  }
}
@keyframes loaderAnimate {
  from {
    transform: rotate(0deg) rotateX(60deg) rotate(45deg);
  }
  to {
    transform: rotate(0deg) rotateX(60deg) rotate(405deg);
  }
}

CSS

.container {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

* {
  box-sizing: border-box;
}

body {
  background-color: #2c153d;
}

.loader {
  position: absolute;
  height: 21.875rem;
  width: 21.875rem;
  transform-style: preserve-3d;
  transform: rotate(0deg) rotateX(60deg) rotate(45deg);
  animation: loaderAnimate 16s linear infinite;
}
.loader .columnWrapper {
  position: absolute;
  transform-style: preserve-3d;
  transform: translateZ(50px);
}
.loader .columnWrapper:nth-child(1) {
  left: 0;
  top: 0;
  transform: translate(0, 0);
}
.loader .columnWrapper:nth-child(2) {
  left: 25%;
  top: 0;
  transform: translate(-25%, 0);
}
.loader .columnWrapper:nth-child(3) {
  left: 50%;
  top: 0;
  transform: translate(-50%, 0);
}
.loader .columnWrapper:nth-child(4) {
  left: 75%;
  top: 0%;
  transform: translate(-75%, 0%);
}
.loader .columnWrapper:nth-child(5) {
  left: 100%;
  top: 0%;
  transform: translate(-100%, 0%);
}
.loader .columnWrapper:nth-child(6) {
  left: 100%;
  top: 25%;
  transform: translate(-100%, -25%);
}
.loader .columnWrapper:nth-child(7) {
  left: 100%;
  top: 50%;
  transform: translate(-100%, -50%);
}
.loader .columnWrapper:nth-child(8) {
  left: 100%;
  top: 75%;
  transform: translate(-100%, -75%);
}
.loader .columnWrapper:nth-child(9) {
  left: 100%;
  top: 100%;
  transform: translate(-100%, -100%);
}
.loader .columnWrapper:nth-child(10) {
  left: 75%;
  top: 100%;
  transform: translate(-75%, -100%);
}
.loader .columnWrapper:nth-child(11) {
  left: 50%;
  top: 100%;
  transform: translate(-50%, -100%);
}
.loader .columnWrapper:nth-child(12) {
  left: 25%;
  top: 100%;
  transform: translate(-25%, -100%);
}
.loader .columnWrapper:nth-child(13) {
  left: 0%;
  top: 100%;
  transform: translate(0%, -100%);
}
.loader .columnWrapper:nth-child(14) {
  left: 0%;
  top: 75%;
  transform: translate(0%, -75%);
}
.loader .columnWrapper:nth-child(15) {
  left: 0%;
  top: 50%;
  transform: translate(0%, -50%);
}
.loader .columnWrapper:nth-child(16) {
  left: 0%;
  top: 25%;
  transform: translate(0%, -25%);
}
.loader .columnWrapper:nth-child(1) .column {
  animation-delay: 0.25s;
}
.loader .columnWrapper:nth-child(2) .column {
  animation-delay: 0.5s;
}
.loader .columnWrapper:nth-child(3) .column {
  animation-delay: 0.75s;
}
.loader .columnWrapper:nth-child(4) .column {
  animation-delay: 1s;
}
.loader .columnWrapper:nth-child(5) .column {
  animation-delay: 1.25s;
}
.loader .columnWrapper:nth-child(6) .column {
  animation-delay: 1.5s;
}
.loader .columnWrapper:nth-child(7) .column {
  animation-delay: 1.75s;
}
.loader .columnWrapper:nth-child(8) .column {
  animation-delay: 2s;
}
.loader .columnWrapper:nth-child(9) .column {
  animation-delay: 2.25s;
}
.loader .columnWrapper:nth-child(10) .column {
  animation-delay: 2.5s;
}
.loader .columnWrapper:nth-child(11) .column {
  animation-delay: 2.75s;
}
.loader .columnWrapper:nth-child(12) .column {
  animation-delay: 3s;
}
.loader .columnWrapper:nth-child(13) .column {
  animation-delay: 3.25s;
}
.loader .columnWrapper:nth-child(14) .column {
  animation-delay: 3.5s;
}
.loader .columnWrapper:nth-child(15) .column {
  animation-delay: 3.75s;
}
.loader .columnWrapper:nth-child(16) .column {
  animation-delay: 4s;
}
.loader .columnWrapper .column {
  height: 60px;
  width: 60px;
  transform-style: preserve-3d;
  transform: translateZ(50px);
  animation: columnAnimate 4s ease forwards infinite;
}
.loader .columnWrapper .column .side {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  height: 200px;
  width: 60px;
}
.loader .columnWrapper .column .side:nth-child(1) {
  transform: translateZ(-100px);
  height: 60px;
}
.loader .columnWrapper .column .side:nth-child(2) {
  transform: translateZ(100px);
  height: 60px;
}
.loader .columnWrapper .column .side:nth-child(3) {
  transform: rotateX(90deg) translateZ(30px);
}
.loader .columnWrapper .column .side:nth-child(4) {
  transform: rotateX(90deg) translateZ(-30px);
}
.loader .columnWrapper .column .side:nth-child(5) {
  transform: rotateX(90deg) rotateY(90deg) translateZ(30px);
}
.loader .columnWrapper .column .side:nth-child(6) {
  transform: rotateX(90deg) rotateY(-90deg) translateZ(30px);
}
.loader .columnWrapper .column .side:nth-child(2) {
  background-color: #decaed;
}
.loader .columnWrapper .column .side:nth-child(3),
.loader .columnWrapper .column .side:nth-child(4),
.loader .columnWrapper .column .side:nth-child(5),
.loader .columnWrapper .column .side:nth-child(6) {
  background-image: linear-gradient(0deg, #decaed, #2c153d 100%, transparent 100%);
}

@keyframes columnAnimate {
  0%, 60%, 100% {
    transform: translateZ(50px);
  }
  40% {
    transform: translateZ(-50px);
  }
}
@keyframes loaderAnimate {
  from {
    transform: rotate(0deg) rotateX(60deg) rotate(45deg);
  }
  to {
    transform: rotate(0deg) rotateX(60deg) rotate(405deg);
  }
}

 

Add a Comment

Your email address will not be published. Required fields are marked *