Animated Game
HTML CODE:-
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <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" /> <title></title> </head> <body> <div class="container"> <i class="fa-solid fa-person-biking"></i> <i class="fa-solid fa-cloud" style="--i:1"></i> <i class="fa-solid fa-cloud" style="--i:2"></i> <i class="fa-solid fa-cloud" style="--i:3"></i> <i class="fa-solid fa-cloud" style="--i:4"></i> <i class="fa-solid fa-cloud" style="--i:5"></i> <i class="fa-solid fa-cloud" style="--i:6"></i> <i class="fa-solid fa-cloud" style="--i:7"></i> <i class="fa-solid fa-cloud" style="--i:8"></i> <i class="fa-solid fa-cloud" style="--i:9"></i> <i class="fa-solid fa-cloud" style="--i:10"></i> <div class="sun"></div> <div class="road"></div> </div> </body> </html> |
CSS CODE:-
body{ margin: 0px; padding: 0px; display: flex; align-items: center; justify-content: center; min-height: 100vh; background: black; } .container{ position: relative; width: 350px; height: 200px; background: white; border-radius: 20px; border: 2px solid white; display: flex; align-items: center; justify-content: center; overflow: hidden; } .sun{ position: absolute; top: 30px; right: 30px; width: 40px; height: 40px; background: #fff; border-radius: 50%; box-shadow: 0px 0px 30px yellow,0px 0px 60px yellow,0px 0px 100px yellow; } .road{ position: absolute; width: 100%; height: 100px; top: 100px; left: 0; background: black; } .road::before{ content: ""; position: absolute; width: 100%; height: 10px; background: green; } .road::after{ content: ""; position: absolute; top: 50%; transform: translateY(-50%); width: 100%; height: 2px; background: repeating-linear-gradient(90deg,transparent 0, transparent 50%,#fff 50%,#fff 100%); background-size: 20px; animation: animate .2s linear infinite; } @keyframes animate{ 0%{ background-position: 0; } 100%{ background-position: -20px; } } .fa-person-biking{ position: absolute; bottom: 50px; left: 30px; color: #e6e1e4; font-size: 50px; z-index: 10; animation:animate1 .2s linear infinite; } @keyframes animate1{ 0%{ transform: translateY(0); } 50%{ transform: translateY(1px); } 100%{ transform: translateY(0); } } .fa-cloud{ position: absolute; top: calc(5px * var(--i)); left: calc(10px * var(--i)); font-size: 30px; color: #d9d5ed; z-index: 1; animation: animate2 3.5s linear infinite; animation-delay: calc(-1s * var(--i)); } @keyframes animate2{ 0%{ transform: translateX(300px); } 100%{ transform: translateX(-300px); } } |