AI CSS Animations

Wallet Card Hover

Three payment cards tucked into a wallet rise out and fan slightly on hover, back card first. Each card reads one --i property for its resting offset, its lift, its tilt and its delay.

Also known as: wallet hover animation css, credit cards slide out, cards in pocket hover.

Travel
Debit
Credit
Wallet3 cards

HTML

<div class="hfx-card-wallet-peek">
  <div class="hfx-card-wallet-peek-card" style="--i: 0"><span>Travel</span></div>
  <div class="hfx-card-wallet-peek-card" style="--i: 1"><span>Debit</span></div>
  <div class="hfx-card-wallet-peek-card" style="--i: 2"><span>Credit</span></div>
  <div class="hfx-card-wallet-peek-pocket"><strong>Wallet</strong><span>3 cards</span></div>
</div>

CSS

.hfx-card-wallet-peek {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  position: relative;
  width: 12em;
  height: 9.6em;
  font-family: system-ui, sans-serif;
}
.hfx-card-wallet-peek-card {
  position: absolute;
  top: 2.6em;
  left: 0.9em;
  right: 0.9em;
  box-sizing: border-box;
  height: 5.6em;
  padding: 0.55em 0.7em;
  border-radius: 0.55em;
  box-shadow: 0 -0.2em 0.5em color-mix(in srgb, #000 18%, transparent);
  color: #fff;
  transform: translateY(calc(var(--i) * 0.5em));
  transition: transform 0.55s cubic-bezier(0.34, 1.4, 0.64, 1);
  transition-delay: calc((2 - var(--i)) * 40ms);
}
.hfx-card-wallet-peek-card:nth-child(1) { background: linear-gradient(135deg, color-mix(in srgb, var(--c) 45%, #1f2937), #111827); }
.hfx-card-wallet-peek-card:nth-child(2) { background: linear-gradient(135deg, color-mix(in oklch, var(--c), #ec4899 55%), color-mix(in oklch, var(--c), #f97316 45%)); }
.hfx-card-wallet-peek-card:nth-child(3) { background: linear-gradient(135deg, color-mix(in srgb, var(--c) 70%, #fff), var(--c)); }
.hfx-card-wallet-peek-card::after {
  content: "";
  position: absolute;
  top: 0.55em;
  right: 0.7em;
  width: 1.3em;
  height: 0.95em;
  border-radius: 0.2em;
  background: linear-gradient(135deg, #fde68a, #d97706);
}
.hfx-card-wallet-peek-card span {
  font-size: 0.62em;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.hfx-card-wallet-peek:hover .hfx-card-wallet-peek-card {
  transform: translateY(calc(-2.3em + var(--i) * 0.75em)) rotate(calc((var(--i) - 1) * -3deg));
  transition-delay: calc(var(--i) * 50ms);
}
.hfx-card-wallet-peek-pocket {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  box-sizing: border-box;
  height: 5.4em;
  padding: 0.8em 1em;
  border-radius: 0.5em 0.5em 0.9em 0.9em;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--c) 18%, #3f3f46), color-mix(in srgb, var(--c) 12%, #27272a));
  box-shadow: 0 -0.15em 0.4em color-mix(in srgb, #000 25%, transparent), 0 0.5em 1em -0.5em color-mix(in srgb, #000 40%, transparent);
  color: #fff;
}
.hfx-card-wallet-peek-pocket::before {
  content: "";
  position: absolute;
  inset: 0.35em;
  border: 1px dashed color-mix(in srgb, #fff 25%, transparent);
  border-radius: 0.3em 0.3em 0.65em 0.65em;
}
.hfx-card-wallet-peek-pocket strong {
  font-size: 0.85em;
  font-weight: 700;
}
.hfx-card-wallet-peek-pocket span {
  font-size: 0.7em;
  opacity: 0.65;
}

@media (prefers-reduced-motion: reduce) {
  .hfx-card-wallet-peek, .hfx-card-wallet-peek *, .hfx-card-wallet-peek::before, .hfx-card-wallet-peek::after, .hfx-card-wallet-peek *::before, .hfx-card-wallet-peek *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --hfx-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --hfx-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar hover effects