Rocket Launch
Home
Snippets
Rocket Launch
HTML
CSS
JS
<div class="scene"> <div class="rocket" id="rocket"> <div class="window"></div> <div class="fin left"></div> <div class="fin right"></div> <div class="flame"></div> </div> </div>
* { box-sizing: border-box; } body { margin: 0; height: 100vh; display: grid; place-items: center; background: radial-gradient( circle at bottom, #172554, #020617 70% ); overflow: hidden; } .scene { position: relative; } .rocket { width: 70px; height: 150px; background: #f1f5f9; border-radius: 50% 50% 20% 20%; animation: float 2s ease-in-out infinite; cursor: pointer; } @keyframes float { 50% { transform: translateY(-12px); } } .window { width: 38px; height: 38px; background: #38bdf8; border: 6px solid #334155; border-radius: 50%; position: absolute; top: 38px; left: 16px; } .fin { width: 30px; height: 55px; background: #ef4444; position: absolute; bottom: 5px; } .left { left: -22px; border-radius: 30px 0 0 10px; } .right { right: -22px; border-radius: 0 30px 10px 0; } .flame { width: 28px; height: 65px; background: linear-gradient( #facc15, #f97316, #ef4444 ); border-radius: 50% 50% 70% 70%; position: absolute; left: 21px; bottom: -79px; animation: fire 0.15s infinite alternate; } .smoke { position: absolute; width: 12px; height: 12px; background: #cbd5e1; border-radius: 50%; pointer-events: none; animation: smoke 1.2s linear forwards; } .rocket.launch { animation: launch 2.5s ease-in forwards; } @keyframes fire { 100% { height: 80px; transform: scaleX(0.8); } } @keyframes smoke { 100% { transform: translate( var(--x), 100px ) scale(4); opacity: 0; } } @keyframes launch { 0% { transform: translateY(0); } 20% { transform: translateY(10px); } 100% { transform: translateY(-700px); } }
const rocket = document.getElementById("rocket"); const scene = document.querySelector(".scene"); let launched = false; function createSmoke() { if (launched) return; const smoke = document.createElement("span"); smoke.className = "smoke"; smoke.style.left = rocket.offsetLeft + 30 + "px"; smoke.style.top = rocket.offsetTop + 190 + "px"; smoke.style.setProperty( "--x", Math.random() * 80 - 40 + "px" ); scene.appendChild(smoke); setTimeout(() => { smoke.remove(); }, 1200); } setInterval(createSmoke, 120); rocket.addEventListener("click", () => { launched = true; rocket.classList.add("launch"); });
Ad #1
Ad #2
Scroll to Top