AI CSS Animations

Glass Card

A frosted-glass card whose blur and border brighten on hover. The frost comes from backdrop-filter, so it looks best over a colorful or busy background.

Also known as: glassmorphism hover, frosted card, blur card.

Glass

Frosted, then a little brighter on hover.

HTML

<article class="hfx-card-glass">
  <h3>Glass</h3>
  <p>Frosted, then a little brighter on hover.</p>
</article>

CSS

.hfx-card-glass {
  --c: var(--hfx-color, #3b82f6);
  font-size: var(--hfx-size, 16px);
  width: 15em;
  padding: 1.2em 1.3em;
  border-radius: 0.9em;
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
  background: color-mix(in srgb, var(--c) 10%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--c);
  font-family: system-ui, sans-serif;
  transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}
.hfx-card-glass:hover {
  background: color-mix(in srgb, var(--c) 18%, transparent);
  border-color: color-mix(in srgb, var(--c) 60%, transparent);
  transform: translateY(-0.2em);
}
.hfx-card-glass h3 { margin: 0 0 0.3em; font-size: 1.1em; }
.hfx-card-glass p  { margin: 0; font-size: 0.85em; opacity: 0.8; }

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