<div id="app">
<div id="wrapper">
<h1 class="glitch" data-text="glitch">glitch</h1>
<span class="sub">EFFECT</span>
</div>
</div>
html,
body,
h1 {
padding: 0;
margin: 0;
font-family: sans-serif;
}
#app {
background: #000;
height: 100vh;
width: 100%;
margin: 0;
padding: 0;
position: relative;
z-index: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-size: cover;
background-position: center;
}
#wrapper {
text-align: center;
}
.sub {
color: #ff4a54;
letter-spacing: 1em;
}
@mixin glitchCopy {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.glitch {
position: relative;
color: #fff;
font-size: 4em;
letter-spacing: 0.5em;
animation: glitch-skew 1s infinite linear alternate-reverse;
&::before {
@include glitchCopy;
left: 2px;
text-shadow: -2px 0 #ff00c1;
clip: rect(44px, 450px, 56px, 0);
animation: glitch-anim 5s infinite linear alternate-reverse;
}
&::after {
@include glitchCopy;
left: -2px;
text-shadow: -2px 0 #ff00c1, 2px 2px #ff00c1;
clip: rect(44px, 450px, 56px, 0);
animation: glitch-anim2 5s infinite linear alternate-reverse;
}
}
@keyframes glitch-anim {
$steps: 20;
@for $i from 0 to $steps {
#{percentage($i*(1/$steps))} {
clip: rect(random(100) + px, 9999px, random(100) + px, 0);
transform: skew((random(100) / 100) + deg);
}
}
}
@keyframes glitch-anim2 {
$steps: 20;
@for $i from 0 to $steps {
#{percentage($i*(1/$steps))} {
clip: rect(random(100) + px, 9999px, random(100) + px, 0);
transform: skew((random(100) / 100) + deg);
}
}
}
@keyframes glitch-skew {
$steps: 10;
@for $i from 0 to $steps {
#{percentage($i*(1/$steps))} {
transform: skew((random(10) - 5) + deg);
}
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.