AI CSS Animations

Datamosh Glitch Text

Thin bands of the word stretch sideways into streaks, as if the video file were corrupted, while the letters snap between skews. Each streak is a clip-path band scaled on the X axis.

Also known as: pixel stretch glitch, smear glitch text, corrupted text effect.

CORRUPT

HTML

<div class="txt-datamosh-glitch" data-text="CORRUPT">CORRUPT</div>

CSS

.txt-datamosh-glitch {
  --c: var(--txt-color, #3b82f6);
  font-size: var(--txt-size, 32px);
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
  position: relative;
  display: inline-block;
  color: var(--c);
  letter-spacing: 0.04em;
  animation: txt-datamosh-glitch-skew 3.2s steps(1, end) infinite;}
.txt-datamosh-glitch::before,
.txt-datamosh-glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  opacity: 0;
  color: var(--c);
  transform-origin: 55% 50%;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent);
  animation: 3.2s steps(1, end) infinite;
}
.txt-datamosh-glitch::before {
  clip-path: inset(24% 0 62% 0);
  animation-name: txt-datamosh-glitch-a;
}
.txt-datamosh-glitch::after {
  clip-path: inset(60% 0 26% 0);
  animation-name: txt-datamosh-glitch-b;
}
@keyframes txt-datamosh-glitch-skew {
  0%, 36%, 74%, 100% { transform: none; }
  30% { transform: skewX(-12deg); }
  33% { transform: skewX(7deg) translateX(0.03em); }
  68% { transform: skewX(16deg) translateX(-0.03em); }
  71% { transform: skewX(-5deg); }
}
@keyframes txt-datamosh-glitch-a {
  0%, 27%, 38%, 66%, 76%, 100% { opacity: 0; transform: none; }
  29% { opacity: 1; transform: scaleX(1.5); }
  32% { opacity: 1; transform: scaleX(1.7) translateX(0.05em); }
  35% { opacity: 0.6; transform: scaleX(1.3) translateX(-0.08em); }
  68% { opacity: 1; transform: scaleX(1.7) translateX(-0.1em); }
  72% { opacity: 1; transform: scaleX(1.2); }
}
@keyframes txt-datamosh-glitch-b {
  0%, 27%, 38%, 66%, 76%, 100% { opacity: 0; transform: none; }
  29% { opacity: 0.7; transform: scaleX(1.3) translateX(-0.06em); }
  33% { opacity: 1; transform: scaleX(1.8) translateX(0.04em); }
  67% { opacity: 1; transform: scaleX(1.6); }
  70% { opacity: 1; transform: scaleX(1.7) translateX(0.08em); }
  73% { opacity: 0.6; transform: scaleX(1.2); }
}

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