Membuat Icon Loading Dengan CSS


Kali ini, kita bisa membuat icon loading hanya dengan CSS saja. Biasanya icon loading kan dibikin dengan gambar berformat .gif. Langsung saja nyok! :)

Kode HTML
<div class="spinner">
<div class="piece a"> </div>
<div class="piece b"> </div>
<div class="piece c"> </div>
<div class="piece d"> </div>
<div class="piece e"> </div>
<div class="piece f"> </div>
<div class="piece g"> </div>
<div class="piece h"> </div>
<div class="piece i"> </div>
<div class="piece j"> </div>
<div class="piece k"> </div>
<div class="piece l"> </div>
<div class="piece m"> </div>
<div class="piece n"> </div>
<div class="piece o"> </div>
<div class="piece p"> </div>
</div>


Kode CSS
.spinner {
width: 32px;
height: 32px;
margin: 50px auto;
}

.piece {
background: #000;
width: 50%;
height: 14%;
position: relative;
}

.spinner div {
opacity: 0.2;
}

@-webkit-keyframes fade {

5% { opacity: 0.8; }
30% { opacity: 0.5; }

}
@-ms-keyframes fade {

5% { opacity: 0.8; }
30% { opacity: 0.5; }

}
@-moz-keyframes fade {

5% { opacity: 0.8; }
30% { opacity: 0.5; }

}

.a, .p {
height: 50%;
width: 14%;
left: 99%;
}

.a {
top: 5%;
-webkit-animation: fade 3.2s ease-in infinite;
-moz-animation: fade 3.2s ease-in infinite;
-ms-animation: fade 3.2s ease-in infinite;
}

.b {
bottom: 21%;
left: 50%;
-webkit-animation: fade 3.2s ease-in-out 3s infinite;
-moz-animation: fade 3.2s ease-in-out 3s infinite;
-ms-animation: fade 3.2s ease-in-out 3s infinite;
}

.c {
bottom: 34%;
left: 110%;
-webkit-animation: fade 3.2s ease-in-out 0.2s infinite;
-moz-animation: fade 3.2s ease-in-out 0.2s infinite;
-ms-animation: fade 3.2s ease-in-out 0.2s infinite;
}

.d {
bottom: 31%;
left: 27%;
-webkit-animation: fade 3.2s ease-in-out 2.8s infinite;
-moz-animation: fade 3.2s ease-in-out 2.8s infinite;
-ms-animation: fade 3.2s ease-in-out 2.8s infinite;
}

.e {
bottom: 43%;
left: 134%;
-webkit-animation: fade 3.2s ease-in-out 0.4s infinite;
-moz-animation: fade 3.2s ease-in-out 0.4s infinite;
-ms-animation: fade 3.2s ease-in-out 0.4s infinite;
}

.f {
bottom: 32%;
left: 11%;
-webkit-animation: fade 3.2s ease-in-out 2.6s infinite;
-moz-animation: fade 3.2s ease-in-out 2.6s infinite;
-ms-animation: fade 3.2s ease-in-out 2.6s infinite;
}

.g {
bottom: 45%;
left: 149%;
-webkit-animation: fade 3.2s ease-in-out 0.6s infinite;
-moz-animation: fade 3.2s ease-in-out 0.6s infinite;
-ms-animation: fade 3.2s ease-in-out 0.6s infinite;
}

.h {
bottom: 30%;
left: 6%;
-webkit-animation: fade 3.2s ease-in-out 2.4s infinite;
-moz-animation: fade 3.2s ease-in-out 2.4s infinite;
-ms-animation: fade 3.2s ease-in-out 2.4s infinite;
}

.i {
bottom: 43%;
left: 155%;
-webkit-animation: fade 3.2s ease-in-out 0.8s infinite;
-moz-animation: fade 3.2s ease-in-out 0.8s infinite;
-ms-animation: fade 3.2s ease-in-out 0.8s infinite;
}
.j {
bottom: 29%;
left: 12%;
-webkit-animation: fade 3.2s ease-in-out 2.2s infinite;
-moz-animation: fade 3.2s ease-in-out 2.2s infinite;
-ms-animation: fade 3.2s ease-in-out 2.2s infinite;
}

.k {
left: 149%;
bottom: 41%;
-webkit-animation: fade 3.2s ease-in-out 1s infinite;
-moz-animation: fade 3.2s ease-in-out 1s infinite;
-ms-animation: fade 3.2s ease-in-out 1s infinite;
}

.l {
bottom: 30%;
left: 28%;
-webkit-animation: fade 3.2s ease-in-out 2s infinite;
-moz-animation: fade 3.2s ease-in-out 2s infinite;
-ms-animation: fade 3.2s ease-in-out 2s infinite;
}

.m {
bottom: 43%;
left: 134%;
-webkit-animation: fade 3.2s ease-in-out 1.2s infinite;
-moz-animation: fade 3.2s ease-in-out 1.2s infinite;
-ms-animation: fade 3.2s ease-in-out 1.2s infinite;
}

.n {
bottom: 40%;
left: 50%;
-webkit-animation: fade 3.2s ease-in-out 1.8s infinite;
-moz-animation: fade 3.2s ease-in-out 1.8s infinite;
-ms-animation: fade 3.2s ease-in-out 1.8s infinite;
}

.o {
left: 110%;
bottom: 52%;
-webkit-animation: fade 3.2s ease-in-out 1.4s infinite;
-moz-animation: fade 3.2s ease-in-out 1.4s infinite;
-ms-animation: fade 3.2s ease-in-out 1.4s infinite;
}
.p {
bottom: 78%;
-webkit-animation: fade 3.2s ease-in-out 1.6s infinite;
-moz-animation: fade 3.2s ease-in-out 1.6s infinite;
-ms-animation: fade 3.2s ease-in-out 1.6s infinite;
}

.b, .o {
-webkit-transform: rotate(67.5deg);
-moz-transform: rotate(67.5deg);
-ms-transform: rotate(67.5deg);
-o-transform: rotate(67.5deg);
}

.d, .m {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
}

.f, .k {
-webkit-transform: rotate(22.5deg);
-moz-transform: rotate(22.5deg);
-ms-transform: rotate(22.5deg);
-o-transform: rotate(22.5deg);

}

.n, .c {
-webkit-transform: rotate(-67.5deg);
-moz-transform: rotate(-67.5deg);
-ms-transform: rotate(-67.5deg);
-o-transform: rotate(-67.5deg);}

.l, .e {
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
}

.j, .g {
-webkit-transform: rotate(-22.5deg);
-moz-transform: rotate(-22.5deg);
-ms-transform: rotate(-22.5deg);
-o-transform: rotate(-22.5deg);
}


Referensi : inserthtml.com

Related Posts

Post a Comment

Subscribe Our Newsletter