Created
September 13, 2016 13:34
-
-
Save sudarshanReddykurri/faf4c57f0ffe7ea09e2345701e2b0d1e to your computer and use it in GitHub Desktop.
Simple Glitch Effect in Pure CSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="#" class="glitch">17</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body{ | |
background-color: #000; | |
} | |
.glitch { | |
font-size: 130px; | |
line-height: 1; | |
font-family: 'Poppins', sans-serif; | |
font-weight: 700; | |
position:absolute; | |
top: 50%; | |
left: 50%; | |
transform: translate(-50%, -50%); | |
margin: 0; | |
text-decoration: none; | |
color: #fff; | |
} | |
.glitch::before { | |
display: block; | |
content: '24'; | |
position: absolute; | |
top: 0; | |
left: 0; | |
height: 100%; | |
width: 100%; | |
opacity: .8; | |
color: #0ff; | |
z-index: -1; | |
} | |
.glitch::after { | |
display: block; | |
content: '24'; | |
position: absolute; | |
top: 0; | |
left: 0; | |
height: 100%; | |
width: 100%; | |
opacity: .8; | |
color: #f0f; | |
z-index: -2; | |
} | |
@keyframes glitch { | |
0% { | |
transform: translate(0) | |
} | |
20% { | |
transform: translate(-5px, 5px) | |
} | |
40% { | |
transform: translate(-5px, -5px) | |
} | |
60% { | |
transform: translate(5px, 5px) | |
} | |
80% { | |
transform: translate(5px, -5px) | |
} | |
to { | |
transform: translate(0) | |
} | |
} | |
.glitch:hover::before { | |
animation: glitch .3s cubic-bezier(.25, .46, .45, .94) both infinite | |
} | |
.glitch:hover::after { | |
animation: glitch .3s cubic-bezier(.25, .46, .45, .94) reverse both infinite | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment