AI CSS Animations

Two-Tone Split Text

A slanted line divides the word into your accent and the page's text color, and slides back and forth. One hard-stop gradient, with currentColor as the second tone so it suits both themes.

Also known as: split color text css, half and half text, duotone text effect.

Day and Night

HTML

<div class="txt-split-color-text">Day and Night</div>

CSS

.txt-split-color-text {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  font-weight: 800;
  background: linear-gradient(110deg,
    var(--c) 49%, color-mix(in srgb, var(--c) 45%, #fff) 49.4%, color-mix(in srgb, var(--c) 45%, #fff) 50.2%, currentColor 50.6%) 0 0 / 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: txt-split-color-text-slide 3.2s cubic-bezier(0.65, 0, 0.35, 1) infinite alternate;}
@keyframes txt-split-color-text-slide {
  from { background-position: 85% 0; }
  to   { background-position: 15% 0; }
}

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