Typography · 08 of 33
Glitch
Two clipped copies of the headline flicker over the original with clip-path and small horizontal shifts, giving a digital glitch look. Toggle the intensity to compare.
<p class="glitch-headline">
<span class="glitch-text glitch-main">Glitch Effect</span>
<span class="glitch-text glitch-r" aria-hidden="true">Glitch Effect</span>
<span class="glitch-text glitch-g" aria-hidden="true">Glitch Effect</span>
</p>
.glitch-headline {
position: relative;
display: inline-block;
font-size: 3.5rem;
font-weight: 600;
}
.glitch-text {
display: block;
position: absolute;
left: 0;
top: 0;
width: 100%;
pointer-events: none;
}
.glitch-main {
position: relative;
color: #f0f0f5;
}
.glitch-r { color: #ff006e; mix-blend-mode: screen; }
.glitch-g { color: #00f5d4; mix-blend-mode: screen; }
var glitchR = document.querySelector('.glitch-r');
var glitchG = document.querySelector('.glitch-g');
var OFFSET = 4; // max px displacement
var OPACITY = 0.25;
function tick() {
var rx = (Math.random() - 0.5) * 2 * OFFSET;
var ry = (Math.random() - 0.5) * 2 * OFFSET;
var gx = (Math.random() - 0.5) * 2 * OFFSET;
var gy = (Math.random() - 0.5) * 2 * OFFSET;
glitchR.style.transform = 'translate(' + rx + 'px, ' + ry + 'px)';
glitchG.style.transform = 'translate(' + gx + 'px, ' + gy + 'px)';
glitchR.style.opacity = OPACITY;
glitchG.style.opacity = OPACITY;
requestAnimationFrame(tick);
}
requestAnimationFrame(tick);