Pure CSS Text Glitch Effect
02/17/2021
Contents
Demo
Code
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>TEXT GLITCH EFFECT</title>
<link rel="stylesheet" type="text/css" href="https://demo.plantpot.works/assets/css/normalize.css">
<link rel="stylesheet" href="https://use.typekit.net/opg3wle.css">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="container">
<div class="text" data-text="GLITCH EFFECT">GLITCH EFFECT</div>
</div>
</body>
</html>
CSS
@charset "utf-8";
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
font-size: 16px;
}
body {
background-color: #000;
font-family: futura-pt, sans-serif;
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
#container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100vh;
}
.text {
position: relative;
color: #fff;
font-size: 4rem;
letter-spacing: 2px;
text-align: center;
animation: skew_text 1.5s linear infinite alternate-reverse;
}
.text::before,
.text::after {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
background-color: #000;
content: attr(data-text);
}
.text::before {
left: -3px;
text-shadow: -2px 0 #69c9d0;
animation: glitch_text_01 1.5s linear infinite alternate-reverse;
}
.text::after {
left: 3px;
text-shadow: -2px 0 #ee1d52;
animation: glitch_text_02 1.5s linear infinite alternate-reverse;
}
@keyframes skew_text {
0% {
transform: skew(-2deg);
}
40% {
transform: skew(2deg);
}
45% {
transform: skew(-2deg);
}
50% {
transform: skew(2deg);
}
100% {
transform: skew(-2deg);
}
}
@keyframes glitch_text_01 {
0% {
clip: rect(80px, auto, 85px, 10px);
}
5% {
clip: rect(84px, auto, 118px, 10px);
}
10% {
clip: rect(22px, auto, 83px, 10px);
}
15% {
clip: rect(15px, auto, 15px, 10px);
}
20% {
clip: rect(116px, auto, 89px, 10px);
}
25% {
clip: rect(95px, auto, 122px, 10px);
}
30% {
clip: rect(108px, auto, 10px, 10px);
}
35% {
clip: rect(118px, auto, 76px, 10px);
}
40% {
clip: rect(53px, auto, 46px, 10px);
}
45% {
clip: rect(131px, auto, 121px, 10px);
}
50% {
clip: rect(79px, auto, 68px, 10px);
}
55% {
clip: rect(40px, auto, 108px, 10px);
}
60% {
clip: rect(25px, auto, 94px, 10px);
}
65% {
clip: rect(125px, auto, 119px, 10px);
}
70% {
clip: rect(59px, auto, 87px, 10px);
}
75% {
clip: rect(70px, auto, 69px, 10px);
}
80% {
clip: rect(109px, auto, 67px, 10px);
}
85% {
clip: rect(29px, auto, 96px, 10px);
}
90% {
clip: rect(41px, auto, 53px, 10px);
}
95% {
clip: rect(110px, auto, 37px, 10px);
}
100% {
clip: rect(90px, auto, 92px, 10px);
}
}
@keyframes glitch_text_02 {
0% {
clip: rect(73px, auto, 132px, 10px);
}
5% {
clip: rect(126px, auto, 60px, 10px);
}
10% {
clip: rect(119px, auto, 28px, 10px);
}
15% {
clip: rect(154px, auto, 40px, 10px);
}
20% {
clip: rect(87px, auto, 64px, 10px);
}
25% {
clip: rect(55px, auto, 19px, 10px);
}
30% {
clip: rect(105px, auto, 115px, 10px);
}
35% {
clip: rect(28px, auto, 95px, 10px);
}
40% {
clip: rect(99px, auto, 27px, 10px);
}
45% {
clip: rect(160px, auto, 30px, 10px);
}
50% {
clip: rect(46px, auto, 102px, 10px);
}
55% {
clip: rect(26px, auto, 106px, 10px);
}
60% {
clip: rect(123px, auto, 8px, 10px);
}
65% {
clip: rect(155px, auto, 123px, 10px);
}
70% {
clip: rect(29px, auto, 118px, 10px);
}
75% {
clip: rect(43px, auto, 24px, 10px);
}
80% {
clip: rect(129px, auto, 67px, 10px);
}
85% {
clip: rect(101px, auto, 127px, 10px);
}
90% {
clip: rect(121px, auto, 0px, 10px);
}
95% {
clip: rect(110px, auto, 84px, 10px);
}
100% {
clip: rect(19px, auto, 112px, 10px);
}
}