.pre-loader { display: flex; width: 100%; min-height: 100vh; justify-content: center; align-items: center; .loader-item { width: 10px; height: 10px; background: black; } .pre-loader-center { align-items: center; display: flex; flex-direction: column; } .pre-loader-wrapper { width: 50px; height: 50px; display: flex; flex-wrap: wrap; } @for $i from 0 through 16 { .loader-item:nth-child(#{$i}) { @if $i % 2 == 0 { animation-delay: #{$i * 50 * random(5)}ms; animation-direction: reverse; } @else { animation-delay: #{$i * -50 * random(5)}ms; animation-direction: alternate; } } } .loader-item { animation: flickering 0.4s linear alternate infinite; } @keyframes flickering { 0% { opacity: 1; } 25% { opacity: 1; } 26% { opacity: 0; } 100% { opacity: 0; } } } html.dark { .pre-loader { .loader-item { background: white; } } }