In this article, we will be learning how to Create Custom Loader With Animation using CSS only.
First, you need to create the following HTML structure.
<!DOCTYPE html> <html> <body> <div class="loader"> <div class="loaderWrap"> <div class="loader__bar"></div> <div class="loader__bar"></div> <div class="loader__bar"></div> <div class="loader__bar"></div> <div class="loader__bar"></div> <div class="loader__ball"> <img src="footer_logo.png"> </div> </div> </div> </body> </html>
And then you need to apply below CSS.
/*For fixed Position Of Loader*/ .loader{ position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); } /*Loader Css Start*/ .loaderWrap { position: relative; width: 75px; height: 120px; } .loader__bar { position: absolute; bottom: 0; width: 10px; height: 50%; background: linear-gradient(to bottom, #06b0f0 0%, #032949 100%); transform-origin: center bottom; box-shadow: 1px 1px 0 rgba(0, 0, 0, .2); } .loader__bar:nth-child(1) { left: 0px; transform: scale(1, 0.2); animation: barLine1 4s infinite; } .loader__bar:nth-child(2) { left: 15px; transform: scale(1, 0.4); animation: barLine2 4s infinite; background: linear-gradient(to bottom, #032949 0%, #06b0f0 100%); } .loader__bar:nth-child(3) { left: 30px; transform: scale(1, 0.6); animation: barLine3 4s infinite; } .loader__bar:nth-child(4) { left: 45px; transform: scale(1, 0.8); animation: barLine4 4s infinite; background: linear-gradient(to bottom, #032949 0%, #06b0f0 100%); } .loader__bar:nth-child(5) { left: 60px; transform: scale(1, 1); animation: barLine5 4s infinite; } .loader__ball img { position: absolute; bottom: 20px; left: 0; width: 12px; height: 12px; animation: logo 4s infinite; } /*End*/
And than you need to add following animation in your CSS file.
@keyframes logo { 0% { transform: translate(0, 0); } 5% { transform: translate(8px, -14px); } 10% { transform: translate(15px, -10px); } 17% { transform: translate(23px, -24px); } 20% { transform: translate(30px, -20px); } 27% { transform: translate(38px, -34px); } 30% { transform: translate(45px, -30px); } 37% { transform: translate(53px, -44px); } 40% { transform: translate(60px, -40px); } 50% { transform: translate(60px, 0); } 57% { transform: translate(53px, -14px); } 60% { transform: translate(45px, -10px); } 67% { transform: translate(37px, -24px); } 70% { transform: translate(30px, -20px); } 77% { transform: translate(22px, -34px); } 80% { transform: translate(15px, -30px); } 87% { transform: translate(7px, -44px); } 90% { transform: translate(0, -40px); } 100% { transform: translate(0, 0); } } @keyframes barLine1 { 0% { transform: scale(1, 0.2); } 40% { transform: scale(1, 0.2); } 50% { transform: scale(1, 1); } 90% { transform: scale(1, 1); } 100% { transform: scale(1, 0.2); } } @keyframes barLine2 { 0% { transform: scale(1, 0.4); } 40% { transform: scale(1, 0.4); } 50% { transform: scale(1, 0.8); } 90% { transform: scale(1, 0.8); } 100% { transform: scale(1, 0.4); } } @keyframes barLine3 { 0% { transform: scale(1, 0.6); } 100% { transform: scale(1, 0.6); } } @keyframes barLine4 { 0% { transform: scale(1, 0.8); } 40% { transform: scale(1, 0.8); } 50% { transform: scale(1, 0.4); } 90% { transform: scale(1, 0.4); } 100% { transform: scale(1, 0.8); } } @keyframes barLine5 { 0% { transform: scale(1, 1); } 40% { transform: scale(1, 1); } 50% { transform: scale(1, 0.2); } 90% { transform: scale(1, 0.2); } 100% { transform: scale(1, 1); } }
Now It’s Ready.
You Can View Following Result.
Excellent!