How To Add Preloader In Website
by Vikash Pareek
HTML
<div class="outer-loader">
<div class="wrap">
<div class="main-loader"></div>
<div class="main-loader"></div>
<div class="main-loader"></div>
<div class="main-loader"></div>
<div class="main-loader"></div>
<div class="main-loader"></div>
<div class="main-loader"></div>
<div class="main-loader"></div>
<div class="main-loader"></div>
<div class="main-loader"></div>
<div class="main-loader"></div>
<div class="main-loader"></div>
<div class="main-loader"></div>
<div class="main-loader"></div>
<div class="main-loader"></div>
</div>
</div>
CSS
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.outer-loader {
background: #000;
height: 100vh;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.wrap {
width: 200px;
display: flex;
justify-content: center;
align-items: center;
}
.main-loader {
height: 100px;
width: 5px;
margin: 0 2px;
border-radius: 5px;
background-image: linear-gradient(180deg,
orange 10%,
white 50%,
green 90%);
transform-origin: bottom;
animation: preloader 1s linear infinite;
}
.main-loader:nth-child(2) {
animation-delay: .1s;
}
.main-loader:nth-child(3) {
animation-delay: .2s;
}
.main-loader:nth-child(4) {
animation-delay: .3s;
}
.main-loader:nth-child(5) {
animation-delay: .4s;
}
.main-loader:nth-child(6) {
animation-delay: .5s;
}
.main-loader:nth-child(7) {
animation-delay: .6s;
}
.main-loader:nth-child(8) {
animation-delay: .7s;
}
.main-loader:nth-child(9) {
animation-delay: .8s;
}
.main-loader:nth-child(10) {
animation-delay: .9s;
}
.main-loader:nth-child(11) {
animation-delay: 1s;
}
.main-loader:nth-child(12) {
animation-delay: 1.1s;
}
.main-loader:nth-child(13) {
animation-delay: 1.2s;
}
.main-loader:nth-child(14) {
animation-delay: 1.3s;
}
.main-loader:nth-child(15) {
animation-delay: 1.4s;
}
@keyframes preloader {
0%,
100% {
transform: scale(1);
}
50% {
transform: scale(.3);
}
}