CSS Tricks9

CSS animated scroll down indicator effect

by Soya Natsuki

HTML

<html>
  <head>
    <title>Scroll down indicator</title>
  </head>
  <body>
    <div class="indicator">
      <span></span>
      <span></span>
      <span></span>
      <span></span>
      <span></span>
    </div>
  </body>
</html>

CSS

body {
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #000;
}

.indicator {
  position: relative;
  width: 50px;
  height: 50px;
  transform: rotate(45deg);
}

.indicator span {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  box-sizing: border-box;
  border: none;
  border-right: 3px solid #fff;
  border-bottom: 3px solid #fff;
  animation: animate 1s linear infinite;
}

.indicator span:nth-child(1) {
  top: -30px;
  left: -30px;
  animation-delay: 0s;
}

.indicator span:nth-child(2) {
  top: -15px;
  left: -15px;
  animation-delay: .2s;
}

.indicator span:nth-child(3) {
  top: 0px;
  left: 0px;
  animation-delay: .4s;
}

.indicator span:nth-child(4) {
  top: 15px;
  left: 15px;
  animation-delay: .6s;
}

.indicator span:nth-child(5) {
  top: 30px;
  left: 30px;
  animation-delay: .8s;
}

@keyframes animate {
  0% {
    border-color: #fff;
    transform: translate(0,0);
  }
  20% {
    border-color: #fff;
    transform: translate(15px,15px);
  }
  20.1%, 100% {
    border-color: #222;
  }
}