AI CSS Animations

Breath Fog on Glass Text

A breath of fog blooms over the word like condensation on a cold window, blurring it, then evaporates from the edges inward until the type is crisp again. One masked backdrop-filter layer.

Also known as: foggy glass text css, fog text effect, condensation text, backdrop blur text animation.

Cold Brew

HTML

<div class="txt-breath-fog-text">
  <span class="txt-breath-fog-text-word">Cold Brew</span>
  <span class="txt-breath-fog-text-fog" aria-hidden="true"></span>
</div>

CSS

.txt-breath-fog-text {
  --c: var(--txt-color, #3b82f6);
  font-size: calc(var(--txt-size, 32px) * 1.6);
  font-family: system-ui, sans-serif;
  font-weight: 800;
  line-height: 1.2;
  position: relative;
  display: inline-block;
  padding: 0.2em 0.4em;
  letter-spacing: -0.01em;}
.txt-breath-fog-text-word {
  color: var(--c);
}
.txt-breath-fog-text-fog {
  position: absolute;
  inset: -0.3em -0.2em;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgb(255 255 255 / 0.42), rgb(226 232 240 / 0.25) 65%, rgb(226 232 240 / 0));
  -webkit-backdrop-filter: blur(0.09em) saturate(0.7);
  backdrop-filter: blur(0.09em) saturate(0.7);
  -webkit-mask: radial-gradient(closest-side, #000 55%, transparent);
  mask: radial-gradient(closest-side, #000 55%, transparent);
  transform: scale(0.1);
  opacity: 0;
  animation: txt-breath-fog-text-breathe 5s cubic-bezier(0.3, 0.7, 0.2, 1) infinite;
}
@keyframes txt-breath-fog-text-breathe {
  0%, 6%  { transform: scale(0.15); opacity: 0; }
  22%     { transform: scale(1.05); opacity: 1; }
  42%     { transform: scale(1.1); opacity: 1; }
  88%     { transform: scale(0.35); opacity: 0; }
  100%    { transform: scale(0.15); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .txt-breath-fog-text-fog { animation: none; }
}

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

Customizing this snippet

  • Color: set --txt-color on the element or a parent. Currently previewing #3b82f6.
  • Font size: set --txt-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 40px.
  • 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 text animations