Toggle navigation
☰
HTML
CSS
Scripting
Database
<!doctype html> <title>Example</title> <style> body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; font-family: sans-serif; background-color: #111; /* Dark theme looks best */ } /* Base text */ .glitch { font-size: 5rem; font-weight: bold; text-transform: uppercase; position: relative; color: white; } /* Define the pseudo-elements that will animate on top of the original */ .glitch::before, .glitch::after { content: attr(data-text); /* Pull the text from the HTML attribute */ position: absolute; top: 0; left: 0; width: 100%; height: 100%; } /* Red channel shifting left */ .glitch::before { left: 2px; text-shadow: -2px 0 red; background: #111; overflow: hidden; animation: noise-anim 2s infinite linear alternate-reverse; } /* Blue channel shifting right */ .glitch::after { left: -2px; text-shadow: -2px 0 blue; background: #111; overflow: hidden; animation: noise-anim-2 3s infinite linear alternate-reverse; } /* Complex keyframes offsetting the clip-path height */ @keyframes noise-anim { 0% { clip-path: inset(40% 0 61% 0); } 20% { clip-path: inset(92% 0 1% 0); } 40% { clip-path: inset(43% 0 1% 0); } 60% { clip-path: inset(25% 0 58% 0); } 80% { clip-path: inset(54% 0 7% 0); } 100% { clip-path: inset(58% 0 43% 0); } } @keyframes noise-anim-2 { 0% { clip-path: inset(26% 0 14% 0); } 20% { clip-path: inset(21% 0 41% 0); } 40% { clip-path: inset(6% 0 48% 0); } 60% { clip-path: inset(80% 0 15% 0); } 80% { clip-path: inset(5% 0 79% 0); } 100% { clip-path: inset(91% 0 7% 0); } } @media (prefers-reduced-motion: reduce) { .glitch::before, .glitch::after { display: none; /* Instantly removes the flashing glitch overlays */ } } </style> <!-- Note the data-text attribute is essential for the pseudo-elements --> <div class="glitch" data-text="ERROR">ERROR</div>