AI CSS Animations

Liquid Fill Text

Outlined letters fill with liquid that rises, drains and rises again, two wave crests rolling across its surface. Three background layers clipped to the text, moved on x and y by two animations.

Also known as: water fill text css, wave fill text animation, text filling with water.

LIQUID

HTML

<div class="txt-liquid-fill-text">LIQUID</div>

CSS

.txt-liquid-fill-text {
  --c: var(--txt-color, #3b82f6);
  font-size: calc(var(--txt-size, 32px) * 1.6);
  font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  font-weight: 900;
  line-height: 1.2;
  display: inline-block;
  letter-spacing: 0.02em;
  -webkit-text-stroke: 0.025em var(--c);
  background-image:
    radial-gradient(50% 100% at 50% 100%, var(--c) 96%, transparent 100%),
    radial-gradient(50% 100% at 50% 100%, color-mix(in srgb, var(--c) 50%, transparent) 96%, transparent 100%),
    linear-gradient(var(--c), var(--c));
  background-size: 1em 0.14em, 1.4em 0.2em, 100% 100%;
  background-repeat: repeat-x, repeat-x, no-repeat;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation:
    txt-liquid-fill-text-flow 1.6s linear infinite,
    txt-liquid-fill-text-level 5s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;}
/* crests move sideways by whole tiles, so the loop has no seam */
@keyframes txt-liquid-fill-text-flow {
  from { background-position-x: 0, 0, 0; }
  to   { background-position-x: 2em, -1.4em, 0; }
}
/* each crest sits on top of the body: level minus the crest height */
@keyframes txt-liquid-fill-text-level {
  from { background-position-y: 0.88em, 0.82em, 1.02em; }
  to   { background-position-y: 0.26em, 0.2em, 0.4em; }
}

@media (prefers-reduced-motion: reduce) {
  .txt-liquid-fill-text, .txt-liquid-fill-text *, .txt-liquid-fill-text::before, .txt-liquid-fill-text::after, .txt-liquid-fill-text *::before, .txt-liquid-fill-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