AI CSS Animations

Glass Credit Card

A frosted payment card with a gold chip that floats with a slow 3D tilt while a holographic sheen slides across. Standard card ratio, masked number, all built from gradients and one pseudo-element.

Also known as: glassmorphism credit card css, glass bank card css, holographic card css.

glass

•••• •••• •••• 2046

Card holderAlex Morgan Expires09/29

HTML

<div class="gls-glass-credit-card">
  <span class="gls-glass-credit-card-orb gls-glass-credit-card-orb-a" aria-hidden="true"></span>
  <span class="gls-glass-credit-card-orb gls-glass-credit-card-orb-b" aria-hidden="true"></span>
  <div class="gls-glass-credit-card-card">
    <div class="gls-glass-credit-card-row">
      <span class="gls-glass-credit-card-brand">glass</span>
      <svg class="gls-glass-credit-card-wave" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M8 7.5a6.5 6.5 0 0 1 0 9M12 5a10 10 0 0 1 0 14M16 2.8a13.5 13.5 0 0 1 0 18.4"/></svg>
    </div>
    <span class="gls-glass-credit-card-chip" aria-hidden="true"></span>
    <p class="gls-glass-credit-card-number">•••• •••• •••• 2046</p>
    <div class="gls-glass-credit-card-row">
      <span class="gls-glass-credit-card-field"><small>Card holder</small>Alex Morgan</span>
      <span class="gls-glass-credit-card-field"><small>Expires</small>09/29</span>
    </div>
  </div>
</div>

CSS

.gls-glass-credit-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) 45%, #0f172a), color-mix(in srgb, var(--c) 20%, #1e1b4b));
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.3;
  perspective: 40em;}
.gls-glass-credit-card-orb {
  position: absolute;
  z-index: -1;
  border-radius: 50%;
}
.gls-glass-credit-card-orb-a {
  left: 3.5em;
  top: 0.4em;
  width: 6.5em;
  height: 6.5em;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 40%, #fff), var(--c) 60%, #7c3aed);
  animation: gls-glass-credit-card-orb 7s ease-in-out infinite alternate;
}
.gls-glass-credit-card-orb-b {
  right: 2.4em;
  bottom: -0.6em;
  width: 5.5em;
  height: 5.5em;
  background: linear-gradient(135deg, #fde68a, #f97316 50%, #db2777);
  animation: gls-glass-credit-card-orb 8s ease-in-out -4s infinite alternate-reverse;
}
.gls-glass-credit-card-card {
  position: relative;
  overflow: hidden;
  display: grid;
  align-content: space-between;
  width: 13.2em;
  height: 8.3em;
  padding: 0.85em 1em;
  border-radius: 0.9em;
  background: color-mix(in srgb, #fff 14%, 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);
  background-image: linear-gradient(135deg, rgb(255 255 255 / 0.22), rgb(255 255 255 / 0.02));
  animation: gls-glass-credit-card-float 6s ease-in-out infinite alternate;
}
.gls-glass-credit-card-card::after {
  content: "";
  position: absolute;
  inset: 0 -100%;
  background: linear-gradient(110deg, transparent 38%, rgb(255 255 255 / 0.28) 45%, rgb(165 243 252 / 0.22) 49%, rgb(251 207 232 / 0.28) 53%, transparent 60%);
  animation: gls-glass-credit-card-sheen 4s ease-in-out infinite;
  pointer-events: none;
}
.gls-glass-credit-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.gls-glass-credit-card-brand {
  font-size: 0.95em;
  font-weight: 800;
  font-style: italic;
  letter-spacing: -0.02em;
}
.gls-glass-credit-card-wave { width: 1.1em; height: 1.1em; opacity: 0.85; }
.gls-glass-credit-card-chip {
  width: 1.9em;
  height: 1.45em;
  border-radius: 0.3em;
  background:
    linear-gradient(90deg, transparent 32%, rgb(120 72 0 / 0.35) 32% 36%, transparent 36% 64%, rgb(120 72 0 / 0.35) 64% 68%, transparent 68%),
    linear-gradient(180deg, transparent 45%, rgb(120 72 0 / 0.35) 45% 55%, transparent 55%),
    linear-gradient(135deg, #fde68a, #d4a017 55%, #fef3c7);
}
.gls-glass-credit-card-number {
  margin: 0;
  font: 600 0.82em/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.06em;
  white-space: nowrap;
  text-shadow: 0 0.05em 0.2em rgb(0 0 0 / 0.3);
}
.gls-glass-credit-card-field {
  display: grid;
  font-size: 0.7em;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-shadow: 0 0.05em 0.3em rgb(0 0 0 / 0.35);
}
.gls-glass-credit-card-field small {
  font-size: 0.72em;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.7;
}
@keyframes gls-glass-credit-card-float {
  from { transform: rotateX(8deg) rotateY(-12deg) translateY(0.2em); }
  to { transform: rotateX(-5deg) rotateY(10deg) translateY(-0.3em); }
}
@keyframes gls-glass-credit-card-sheen {
  0% { transform: translateX(-35%); }
  60%, 100% { transform: translateX(35%); }
}
@keyframes gls-glass-credit-card-orb {
  to { transform: translate(1.5em, 1.2em) scale(1.1); }
}

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

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