AI CSS Animations

Image Fill Text Hover

A solid headline turns into a window onto a sunset scene on hover. The scene is layered gradients clipped to the text, revealed by fading the text color to transparent.

Also known as: image inside text on hover, background clip text image, photo text fill.

Wander

HTML

<div class="hfx-text-image-fill">Wander</div>

CSS

.hfx-text-image-fill {
  --c: var(--hfx-color, #3b82f6);
  font-size: calc(var(--hfx-size, 16px) * 2.8);
  font-family: system-ui, sans-serif;
  font-weight: 800;
  line-height: 1.15;
  cursor: default;
  display: inline-block;
  font-weight: 900;
  color: var(--c);
  background:
    radial-gradient(circle at 68% 40%, #fef9c3 0 0.16em, #fcd34d 0.2em, transparent 0.45em),
    radial-gradient(38% 55% at 22% 100%, color-mix(in srgb, var(--c) 30%, #14532d) 97%, transparent),
    radial-gradient(50% 48% at 78% 104%, color-mix(in srgb, var(--c) 20%, #15803d) 97%, transparent),
    radial-gradient(70% 45% at 50% 100%, color-mix(in srgb, var(--c) 35%, #4d7c0f) 97%, transparent),
    linear-gradient(color-mix(in srgb, var(--c) 40%, #fff) 10%, color-mix(in srgb, var(--c) 45%, #fb7185));
  background-size: 140% 140%;
  background-position: 50% 30%;
  -webkit-background-clip: text;
  background-clip: text;
  transition: color 0.5s ease, background-size 0.9s cubic-bezier(0.22, 1, 0.36, 1),
    background-position 0.9s cubic-bezier(0.22, 1, 0.36, 1);}
.hfx-text-image-fill:hover {
  color: transparent;
  background-size: 100% 100%;
  background-position: 50% 50%;
}

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