Custom Preloader Animation code:
1.index.html:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Preloader</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="center"> <span></span> <span></span> <span></span> <span></span> </div> </body> </html>
2.style.css:
body { margin: 0; padding: 0; } .center { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); } span { position: absolute; width: 20px; height: 20px; background: black; animation: animate 4s infinite ease-in-out; } span:nth-child(1) { background: blue; left: -24px; top: -24px; animation-delay: 0.2s; } span:nth-child(2) { background: red; left: 0; top: -24px; animation-delay: 0.4s; } span:nth-child(3) { background: red; left: -24px; top: 0; animation-delay: 0.6s; } span:nth-child(4) { background: blue; left: 0; top: 0; animation-delay: 0.8s; } @keyframes animate { 0% { transform: rotateY(0deg); } 20% { transform: rotateY(360deg); } 40% { transform: rotateX(180deg); } 60% { transform: rotateX(0deg); } 80% { transform: rotateX(360deg); } 100% { transform: rotateY(360deg); } }