doughnut-loader

simple doughnut loading animation using CSS. Here's an example:

by oktaviardi pratama

HTML

<div class="example1">
  <div class="doughnut-loader">
    <div class="doughnut"></div>
  </div>
</div>

<div class="example2">
  <div class="loader"></div>
</div

<div class="example3">
  <div class="loader">
    <div class="bar"></div>
    <div class="bar"></div>
    <div class="bar"></div>
    <div class="bar"></div>
    <div class="bar"></div>
  </div>
</div>

SCSS

.example1 {
  .doughnut-loader {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

.doughnut {
  width: 80px;
  height: 80px;
  border: 10px solid #ccc;
  border-top-color: #f96332;
  border-radius: 50%;
  animation: spin 2s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0); }
  100% { transform: rotate(360deg); }
}

}

.example2 {
  .loader {
  position: relative;
  width: 60px;
  height: 60px;
  margin: 0 auto;
}

.loader:before,
.loader:after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0);
  animation: loader-animation 2s ease-out infinite;
}

.loader:before {
  border: 4px solid #3498db;
  border-right-color: transparent;
}

.loader:after {
  border: 4px solid #f1c40f;
  border-top-color: transparent;
  animation-delay: 1s;
}

@keyframes loader-animation {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1);
  }
}
}

.example3 {
  .loader {
  position: relative;
  width: 60px;
  height: 20px;
  margin: 0 auto;
}

.bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 8px;
  height: 20px;
  margin: 0 2px;
  background-color: #3498db;
  animation: loader-animation 1s ease-in-out infinite;
}

.bar:nth-child(1) {
  animation-delay: 0;
}

.bar:nth-child(2) {
  animation-delay: 0.2s;
}

.bar:nth-child(3) {
  animation-delay: 0.4s;
}

.bar:nth-child(4) {
  animation-delay: 0.6s;
}

.bar:nth-child(5) {
  animation-delay: 0.8s;
}

@keyframes loader-animation {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.5);
  }
  100% {
    transform: scale(1);
  }
}
}