Duel Cards Collide

Two cards fly in from opposite sides, collide in the middle with a spark at the contact point, then bounce apart and settle. Good for an A-versus-B comparison or a question-versus-question beat.

Motion specs

Duration
3.6s
Easing
cubic-bezier(.2,1.4,.4,1)
Technique
WAAPI transforms
Library
Web Animations API / CSS Transitions
Category
Scene Transitions
License
Free for personal and commercial use
AI prompt
Create a web animation named "Duel Cards Collide": #0d0e11 background, one orange #ff5e1a card with dark text and one dark #16181e card with an orange border, both 150x110 with 16px radius. They start outside the frame (translateX ±420px, 14deg rotation, 0.86 scale) and travel to the centre over 500ms with cubic-bezier(.16,1,.3,1); on contact they squash for 40ms, a white spark flashes and expands 9x while fading, then both cards bounce apart with cubic-bezier(.2,1.4,.4,1). The sequence loops every 3.6s.
Full code (HTML + CSS + JS)
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Duel Cards Collide</title>
<style>
body{margin:0;background:#0d0e11;color:#f3f4f6;font-family:system-ui,sans-serif;display:grid;place-items:center;min-height:100vh}
.stage{position:relative;width:100%;max-width:520px;height:260px;overflow:hidden}
.card{position:absolute;top:50%;left:50%;width:150px;height:110px;margin:-55px 0 0 -75px;border-radius:16px;display:grid;place-items:center;font-weight:800;font-size:20px;letter-spacing:.06em;will-change:transform;box-shadow:0 12px 30px rgba(0,0,0,.45)}
.a{background:#ff5e1a;color:#0d0e11}
.b{background:#16181e;color:#ff5e1a;border:2px solid #ff5e1a}
.spark{position:absolute;top:50%;left:50%;width:10px;height:10px;margin:-5px 0 0 -5px;border-radius:50%;background:#fff;opacity:0}
@media (prefers-reduced-motion: reduce){*{animation:none!important;transition:none!important}}
</style></head><body><div class="stage" id="s"><div class="card a">FRUIT?</div><div class="card b">SEED?</div><div class="spark" id="sp"></div></div>
<script>
const a=document.querySelector('.a'),b=document.querySelector('.b'),sp=document.getElementById('sp');
function play(){
  a.style.transition='none';a.style.transform='translateX(-420px) rotate(-14deg) scale(.86)';
  b.style.transition='none';b.style.transform='translateX(420px) rotate(14deg) scale(.86)';
  sp.style.transition='none';sp.style.opacity='0';sp.style.transform='scale(1)';
  setTimeout(()=>{
    a.style.transition='transform .5s cubic-bezier(.16,1,.3,1)';a.style.transform='translateX(-8px) rotate(0deg) scale(1)';
    b.style.transition='transform .5s cubic-bezier(.16,1,.3,1)';b.style.transform='translateX(8px) rotate(0deg) scale(1)';
  },120);
  setTimeout(()=>{
    a.style.transition='transform .22s ease-out';a.style.transform='translateX(-14px) rotate(-3deg) scale(.97)';
    b.style.transition='transform .22s ease-out';b.style.transform='translateX(14px) rotate(3deg) scale(.97)';
    sp.style.transition='opacity .12s ease-out';sp.style.opacity='1';sp.style.transform='scale(1)';
  },640);
  setTimeout(()=>{
    sp.style.transition='transform .5s ease-out,opacity .5s ease-out';sp.style.transform='scale(9)';sp.style.opacity='0';
    a.style.transition='transform .55s cubic-bezier(.2,1.4,.4,1)';a.style.transform='translateX(-150px) rotate(-8deg) scale(1)';
    b.style.transition='transform .55s cubic-bezier(.2,1.4,.4,1)';b.style.transform='translateX(150px) rotate(8deg) scale(1)';
  },760);
}
play();setInterval(play,3600);
</script></body></html>

Related templates