Skip to content

Instantly share code, notes, and snippets.

@yuri-ktm
Created August 21, 2021 07:14
Show Gist options
  • Select an option

  • Save yuri-ktm/48604119adb0d200097dbfc367f87ec7 to your computer and use it in GitHub Desktop.

Select an option

Save yuri-ktm/48604119adb0d200097dbfc367f87ec7 to your computer and use it in GitHub Desktop.
Glitch
<h1 class="glitch" data-text="Glitch">Glitch</h1>
$primaryColor: #fd5f00;
$secondaryColor: #f7f3e9;
$steps: 20;
body {
background-color: $secondaryColor;
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.glitch {
position: relative;
font-family: sans-serif;
font-size: 7em;
text-transform: uppercase;
text-shadow: 6px -6px 0px #fd5f00;
background: repeating-linear-gradient(45deg, #005792, #005792 1px, #fff 2px, #fff 3px);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
&::before,
&::after {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
right: 0;
background: $secondaryColor;
color: $primaryColor;
clip: rect(0, 900px, 0, 0);
overflow: hidden;
}
&::before {
left: 7px;
text-shadow: 1px 0 #fd5f00;
animation: glitch-effect 3s infinite linear alternate-reverse;
}
&::after {
left: 3px;
text-shadow: -1px 0 #fd5f00;
animation: glitch-effect 2s infinite linear alternate-reverse;
}
}
@keyframes glitch-effect{
@for $i from 0 through $steps{
#{percentage($i*(1/$steps))}{
clip: rect(random(100) + px, 9999px, random(100) + px, 0);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment