Car Animation
HTML CODE:-
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A==" crossorigin="anonymous" referrerpolicy="no-referrer" /> </head> <body> <div class="container"> <span style="--i:1"></span> <span style="--i:2"></span> <span style="--i:3"></span> <span style="--i:4"></span> <span style="--i:5"></span> <span style="--i:6"></span> <span style="--i:7"></span> <span style="--i:8"></span> <span style="--i:9"></span> <span style="--i:10"></span> <span style="--i:11"></span> <span style="--i:12"></span> <span style="--i:13"></span> <span style="--i:14"></span> <span style="--i:15"></span> <span style="--i:16"></span> <span style="--i:17"></span> <span style="--i:18"></span> <span style="--i:19"></span> <span style="--i:20"></span> <div class="icon"> <i class="fa-solid fa-car-side"></i> </div> </div> </body> </html> |
CSS CODE:-
body{ padding: 0px; margin: 0px; display: flex; align-items: center; justify-content: center; min-height: 100vh; background: black; } .container{ position: relative; width: 150px; height: 150px; } .container span{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; transform: rotate(calc(18deg*var(--i))); } .container span::before{ content: ""; position: absolute; top: 0; left: 0; width: 13px; height: 13px; background: white; border-radius: 81% 19% 69% 31% / 31% 47% 53% 69% ; transform: scale(0); animation: animate 2s linear infinite; animation-delay: calc(0.1s * var(--i)); } @keyframes animate{ 0%{ transform: scale(0); } 10%{ transform: scale(1.2); } 80%,100%{ transform: scale(0); } } .icon{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; animation: animate1 2s linear infinite; animation-delay: -1s; } @keyframes animate1{ 0%{ transform: rotate(10deg); } 100%{ transform: rotate(360deg); } } .icon i{ position: absolute; top: 130px; left: 135px; color: white; font-size: 30px; transform: rotate(90deg); } |