AI CSS Animations

Glassmorphism Card

The classic glassmorphism card: a frosted pane over two gradient orbs that slowly circle behind it, so you watch the blur at work. Semi-transparent fill, backdrop-filter, rim light.

Also known as: glass card css, glassmorphism card html css, frosted glass card.

Frosted glass

A translucent pane over slowly moving color.

HTML

<div class="gls-glassmorphism-card">
  <div class="gls-glassmorphism-card-orbit" aria-hidden="true">
    <span class="gls-glassmorphism-card-blob"></span>
    <span class="gls-glassmorphism-card-blob"></span>
  </div>
  <article class="gls-glassmorphism-card-pane">
    <span class="gls-glassmorphism-card-icon" aria-hidden="true">
      <svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 3l2 7 7 2-7 2-2 7-2-7-7-2 7-2z"/></svg>
    </span>
    <h3 class="gls-glassmorphism-card-title">Frosted glass</h3>
    <p class="gls-glassmorphism-card-text">A translucent pane over slowly moving color.</p>
  </article>
</div>

CSS

.gls-glassmorphism-card {
  --c: var(--gls-color, #3b82f6);
  font-size: var(--gls-size, 16px);
  position: relative;
  display: grid;
  place-items: center;
  width: 22em;
  height: 12em;
  border-radius: 1.25em;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 40%, #0f172a), color-mix(in srgb, var(--c) 25%, #312e81));
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.3;
}
.gls-glassmorphism-card-orbit {
  position: absolute;
  inset: 0;
  animation: gls-glassmorphism-card-spin 16s linear infinite;
}
.gls-glassmorphism-card-blob {
  position: absolute;
  border-radius: 50%;
}
.gls-glassmorphism-card-blob:nth-child(1) {
  left: 3.6em;
  top: 0.1em;
  width: 6.4em;
  height: 6.4em;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 40%, #fff), var(--c));
}
.gls-glassmorphism-card-blob:nth-child(2) {
  right: 3.9em;
  bottom: 0.9em;
  width: 5.4em;
  height: 5.4em;
  background: linear-gradient(135deg, #fcd34d, #ec4899);
}
.gls-glassmorphism-card-pane {
  position: relative;
  width: 13.5em;
  padding: 1em 1.25em 1.2em;
  border-radius: 1em;
  background: color-mix(in srgb, #fff 18%, transparent);
  -webkit-backdrop-filter: blur(0.9em) saturate(1.5);
  backdrop-filter: blur(0.9em) saturate(1.5);
  border: 1px solid color-mix(in srgb, #fff 45%, transparent);
  box-shadow: 0 0.5em 1.5em -0.5em rgb(0 0 0 / 0.35), inset 0 1px 0 color-mix(in srgb, #fff 55%, transparent);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.gls-glassmorphism-card-pane:hover { transform: translateY(-0.25em); }
.gls-glassmorphism-card-icon {
  display: grid;
  place-items: center;
  width: 2em;
  height: 2em;
  margin-bottom: 0.7em;
  border-radius: 0.6em;
  background: rgb(255 255 255 / 0.2);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.5);
}
.gls-glassmorphism-card-icon svg { width: 1.1em; height: 1.1em; }
.gls-glassmorphism-card-title { margin: 0; font-size: 1.05em; font-weight: 650; }
.gls-glassmorphism-card-text {
  margin: 0.3em 0 0;
  font-size: 0.78em;
  line-height: 1.45;
  color: rgb(255 255 255 / 0.82);
}
@keyframes gls-glassmorphism-card-spin {
  to { transform: rotate(1turn); }
}

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

Tailwind CSS version

The same effect using Tailwind utility classes. No custom CSS or config needed.

<div class="relative grid h-48 w-[22rem] place-items-center overflow-hidden rounded-[1.25rem] bg-gradient-to-br from-slate-900 to-indigo-900 font-sans text-white">
  <div class="absolute inset-0 animate-[spin_16s_linear_infinite]" aria-hidden="true">
    <span class="absolute left-[3.6rem] top-[0.1rem] h-[6.4rem] w-[6.4rem] rounded-full bg-gradient-to-br from-sky-300 to-blue-500"></span>
    <span class="absolute bottom-[0.9rem] right-[3.9rem] h-[5.4rem] w-[5.4rem] rounded-full bg-gradient-to-br from-amber-300 to-pink-500"></span>
  </div>
  <article class="relative w-[13.5rem] rounded-2xl border border-white/45 bg-white/[0.18] px-5 pb-5 pt-4 shadow-[0_0.5rem_1.5rem_-0.5rem_rgb(0_0_0/0.35),inset_0_1px_0_rgb(255_255_255/0.55)] backdrop-blur-[0.9rem] backdrop-saturate-150 transition-transform duration-[400ms] ease-out hover:-translate-y-1">
    <span class="mb-3 grid h-8 w-8 place-items-center rounded-[0.6rem] bg-white/20 shadow-[inset_0_1px_0_rgb(255_255_255/0.5)]" aria-hidden="true">
      <svg class="h-[1.1rem] w-[1.1rem]" viewBox="0 0 24 24" fill="currentColor"><path d="M12 3l2 7 7 2-7 2-2 7-2-7-7-2 7-2z"/></svg>
    </span>
    <h3 class="text-[1.05rem] font-semibold">Frosted glass</h3>
    <p class="mt-1 text-[0.78rem] leading-relaxed text-white/80">A translucent pane over slowly moving color.</p>
  </article>
</div>

Customizing this snippet

  • Color: set --gls-color on the element or a parent. Currently previewing #3b82f6.
  • Base size: set --gls-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 glass effects