Animated Text Glitch Effect In Pure CSS

Category: Animation , CSS & CSS3 , Text | August 5, 2020
Author: Madhav52
Views Total: 289 views
Official Page: Go to website
Last Update: August 5, 2020
License: MIT

Preview:

Animated Text Glitch Effect In Pure CSS

Description:

Yet another CSS solution to apply an animated glitch effect to your text using CSS animation and clip properties.

How to use it:

1. Define the glitch text in the data-text attribute as follows:

<h1 class="glitch" data-text="CSSScript">CSSScript</h1>

2. The needed CSS rules to create a glitch effect.

.glitch:before,
.glitch:after {
  padding: 30px;
  color: white;
  content: attr(data-text);
  position: absolute;
  width: 100%;
  height: 100%;
  background: black;
  overflow: hidden;
  top: 0;
}

.glitch:before{
  left: 3px;
  text-shadow: -2px 0 #d8031c;
  animation: glitch-1 2s linear infinite reverse;
}

.glitch:after{
  left: -3px;
  text-shadow: -2px 0 #00008B;
  animation: glitch-2 2s linear infinite reverse;
}

@keyframes glitch-1 {
  0% {
    clip: rect(132px, 350px, 101px, 30px);
  }
  5% {
    clip: rect(17px, 350px, 94px, 30px);
  }
  10% {
    clip: rect(40px, 350px, 66px, 30px);
  }
  15% {
    clip: rect(87px, 350px, 82px, 30px);
  }
  20% {
    clip: rect(137px, 350px, 61px, 30px);
  }
  25% {
    clip: rect(34px, 350px, 14px, 30px);
  }
  30% {
    clip: rect(133px, 350px, 74px, 30px);
  }
  35% {
    clip: rect(76px, 350px, 107px, 30px);
  }
  40% {
    clip: rect(59px, 350px, 130px, 30px);
  }
  45% {
    clip: rect(29px, 350px, 84px, 30px);
  }
  50% {
    clip: rect(22px, 350px, 67px, 30px);
  }
  55% {
    clip: rect(67px, 350px, 62px, 30px);
  }
  60% {
    clip: rect(10px, 350px, 105px, 30px);
  }
  65% {
    clip: rect(78px, 350px, 115px, 30px);
  }
  70% {
    clip: rect(105px, 350px, 13px, 30px);
  }
  75% {
    clip: rect(15px, 350px, 75px, 30px);
  }
  80% {
    clip: rect(66px, 350px, 39px, 30px);
  }
  85% {
    clip: rect(133px, 350px, 73px, 30px);
  }
  90% {
    clip: rect(36px, 350px, 128px, 30px);
  }
  95% {
    clip: rect(68px, 350px, 103px, 30px);
  }
  100% {
    clip: rect(14px, 350px, 100px, 30px);
  }
}
@keyframes glitch-2 {
  0% {
    clip: rect(129px, 350px, 36px, 30px);
  }
  5% {
    clip: rect(36px, 350px, 4px, 30px);
  }
  10% {
    clip: rect(85px, 350px, 66px, 30px);
  }
  15% {
    clip: rect(91px, 350px, 91px, 30px);
  }
  20% {
    clip: rect(148px, 350px, 138px, 30px);
  }
  25% {
    clip: rect(38px, 350px, 122px, 30px);
  }
  30% {
    clip: rect(69px, 350px, 54px, 30px);
  }
  35% {
    clip: rect(98px, 350px, 71px, 30px);
  }
  40% {
    clip: rect(146px, 350px, 34px, 30px);
  }
  45% {
    clip: rect(134px, 350px, 43px, 30px);
  }
  50% {
    clip: rect(102px, 350px, 80px, 30px);
  }
  55% {
    clip: rect(119px, 350px, 44px, 30px);
  }
  60% {
    clip: rect(106px, 350px, 99px, 30px);
  }
  65% {
    clip: rect(141px, 350px, 74px, 30px);
  }
  70% {
    clip: rect(20px, 350px, 78px, 30px);
  }
  75% {
    clip: rect(133px, 350px, 79px, 30px);
  }
  80% {
    clip: rect(78px, 350px, 52px, 30px);
  }
  85% {
    clip: rect(35px, 350px, 39px, 30px);
  }
  90% {
    clip: rect(67px, 350px, 70px, 30px);
  }
  95% {
    clip: rect(71px, 350px, 103px, 30px);
  }
  100% {
    clip: rect(83px, 350px, 40px, 30px);
  }
}

You Might Be Interested In:


Leave a Reply