AI CSS Animations

Music Player Card Hover

A track row where the cover art dims, a play button springs up over it and the little equalizer comes alive. Each bar has its own duration, so the bounce never looks like a loop.

Also known as: music card hover css, album card play button, spotify style card hover.

Harbour Lights

Mira Vale

HTML

<article class="hfx-card-music-play">
  <div class="hfx-card-music-play-art">
    <button class="hfx-card-music-play-btn" aria-label="Play Harbour Lights"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M8 5.5v13l10.5-6.5z"/></svg></button>
  </div>
  <div class="hfx-card-music-play-info">
    <h3>Harbour Lights</h3>
    <p>Mira Vale</p>
  </div>
  <span class="hfx-card-music-play-eq" aria-hidden="true"><i style="--i: 0; --h: 0.55"></i><i style="--i: 1; --h: 0.9"></i><i style="--i: 2; --h: 0.4"></i><i style="--i: 3; --h: 0.7"></i></span>
</article>

CSS

.hfx-card-music-play {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  width: 15em;
  border-radius: 0.75em;
  overflow: hidden;
  background: #fff;
  border: 1px solid color-mix(in srgb, #000 10%, transparent);
  color: #1f2937;
  font-family: system-ui, sans-serif;
  display: flex;
  align-items: center;
  gap: 0.85em;
  box-sizing: border-box;
  width: 16em;
  padding: 0.65em 1em 0.65em 0.65em;
  transition: background-color 0.3s ease, box-shadow 0.35s ease;}
.hfx-card-music-play:is(:hover, :focus-within) {
  background: color-mix(in srgb, var(--c) 6%, #fff);
  box-shadow: 0 0.8em 1.3em -0.9em color-mix(in srgb, #000 30%, transparent);
}
.hfx-card-music-play-art {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 4em;
  height: 4em;
  overflow: hidden;
  border-radius: 0.55em;
  background:
    radial-gradient(circle at 50% 50%, #fff 0 6%, transparent 7%),
    repeating-radial-gradient(circle at 50% 50%, color-mix(in srgb, #000 0%, transparent) 0 0.18em, color-mix(in srgb, #000 18%, transparent) 0.2em 0.22em),
    conic-gradient(from 210deg, var(--c), color-mix(in oklch, var(--c), #ec4899 60%), color-mix(in oklch, var(--c), #fde047 45%), var(--c));
}
.hfx-card-music-play-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, #000 40%, transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.hfx-card-music-play:is(:hover, :focus-within) .hfx-card-music-play-art::after { opacity: 1; }
.hfx-card-music-play-btn {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 2em;
  height: 2em;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0.2em 0.6em color-mix(in srgb, #000 30%, transparent);
  color: var(--c);
  cursor: pointer;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.25s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.hfx-card-music-play:is(:hover, :focus-within) .hfx-card-music-play-btn {
  opacity: 1;
  transform: none;
}
.hfx-card-music-play-btn svg {
  width: 1em;
  height: 1em;
  margin-left: 0.1em;
  fill: currentColor;
}
.hfx-card-music-play-info {
  flex: 1;
  min-width: 0;
}
.hfx-card-music-play h3 {
  margin: 0;
  font-size: 0.95em;
  font-weight: 600;
  transition: color 0.3s ease;
}
.hfx-card-music-play:is(:hover, :focus-within) h3 { color: var(--c); }
.hfx-card-music-play p {
  margin: 0.15em 0 0;
  font-size: 0.78em;
  color: #6b7280;
}
.hfx-card-music-play-eq {
  display: flex;
  align-items: flex-end;
  gap: 0.16em;
  height: 1.1em;
}
.hfx-card-music-play-eq i {
  width: 0.22em;
  height: 100%;
  border-radius: 0.1em;
  background: color-mix(in srgb, var(--c) 30%, transparent);
  transform-origin: 50% 100%;
  transform: scaleY(var(--h));
  transition: background-color 0.3s ease;
}
.hfx-card-music-play:is(:hover, :focus-within) .hfx-card-music-play-eq i {
  background: var(--c);
  animation: hfx-card-music-play-eq calc(0.55s + var(--i) * 0.12s) ease-in-out calc(var(--i) * -0.2s) infinite alternate;
}
@keyframes hfx-card-music-play-eq {
  from { transform: scaleY(0.2); }
  to { transform: scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
  .hfx-card-music-play, .hfx-card-music-play *, .hfx-card-music-play::before, .hfx-card-music-play::after, .hfx-card-music-play *::before, .hfx-card-music-play *::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