Robert Crocker

Craft obsessed developer who designs.

← Back to the lab

39Rocket Ship

III · Particles & Play

Exhaust particles spawn on an interval beneath a gently hovering rocket.

Auto

Source

3 files
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>CodeSandbox</title>
  </head>
  <body>
    <style>
      @keyframes oscillate {
        from {
          transform: translateY(-5%);
        }
        to {
          transform: translateY(5%);
        }
      }
      @keyframes fadeToTransparent {
        to {
          opacity: 0;
        }
      }
      @keyframes disperse {
        to {
          transform: translate(var(--x), var(--y));
        }
      }
    
      .rocketWrapper {
        position: relative;
      }
      .rocket {
        position: relative;
        animation: oscillate 1500ms ease-in-out infinite alternate;
      }
      .particle {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 20px;
        margin-inline: auto;
        animation:
          disperse 750ms forwards,
          fadeToTransparent var(--fade-duration) var(--fade-delay) forwards;
      }
    </style>
    
    <div class="rocketWrapper">
      <img
        class="rocket"
        alt="A cute 3D illustration of a rocketship made of clay"
        src="https://sandpack-bundler.vercel.app/img/clay-rocket.png"
      />
    </div>
  </body>
</html>