diff options
Diffstat (limited to '')
-rw-r--r-- | glitch.css | 196 |
1 files changed, 196 insertions, 0 deletions
diff --git a/glitch.css b/glitch.css new file mode 100644 index 0000000..b07e7be --- /dev/null +++ b/glitch.css @@ -0,0 +1,196 @@ +/* Our mixin positions a copy of our text +directly on our existing text, while +also setting content to the appropriate +text set in the data-text attribute. */ +.glitch { + position: relative; + color: white; + font-size: 12px; + letter-spacing: .5em; + /* Animation provies a slight random skew. Check bottom of doc + for more information on how to random skew. */ + animation: glitch-skew 1s infinite linear alternate-reverse; } + .glitch::before { + content: attr(data-text); + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + left: 2px; + text-shadow: -2px 0 #ff00c1; + /* Creates an initial clip for our glitch. This works in + a typical top,right,bottom,left fashion and creates a mask + to only show a certain part of the glitch at a time. */ + clip: rect(44px, 450px, 56px, 0); + /* Runs our glitch-anim defined below to run in a 5s loop, infinitely, + with an alternating animation to keep things fresh. */ + animation: glitch-anim 5s infinite linear alternate-reverse; } + .glitch::after { + content: attr(data-text); + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + left: -2px; + text-shadow: -2px 0 #00fff9, 2px 2px #ff00c1; + animation: glitch-anim2 1s infinite linear alternate-reverse; } + +/* Creates an animation with 20 steaps. For each step, it calculates +a percentage for the specific step. It then generates a random clip +box to be used for the random glitch effect. Also adds a very subtle +skew to change the 'thickness' of the glitch.*/ +@keyframes glitch-anim { + 0% { + clip: rect(61px, 9999px, 7px, 0); + transform: skew(0.17deg); } + 5% { + clip: rect(9px, 9999px, 91px, 0); + transform: skew(0.24deg); } + 10% { + clip: rect(24px, 9999px, 95px, 0); + transform: skew(0.69deg); } + 15% { + clip: rect(78px, 9999px, 69px, 0); + transform: skew(0.32deg); } + 20% { + clip: rect(99px, 9999px, 59px, 0); + transform: skew(0.55deg); } + 25% { + clip: rect(20px, 9999px, 92px, 0); + transform: skew(0.62deg); } + 30% { + clip: rect(90px, 9999px, 77px, 0); + transform: skew(0.2deg); } + 35% { + clip: rect(54px, 9999px, 41px, 0); + transform: skew(0.93deg); } + 40% { + clip: rect(29px, 9999px, 66px, 0); + transform: skew(0.76deg); } + 45% { + clip: rect(53px, 9999px, 42px, 0); + transform: skew(0.3deg); } + 50% { + clip: rect(5px, 9999px, 22px, 0); + transform: skew(0.48deg); } + 55% { + clip: rect(3px, 9999px, 31px, 0); + transform: skew(0.71deg); } + 60% { + clip: rect(61px, 9999px, 66px, 0); + transform: skew(0.64deg); } + 65% { + clip: rect(85px, 9999px, 96px, 0); + transform: skew(0.7deg); } + 70% { + clip: rect(9px, 9999px, 49px, 0); + transform: skew(0.14deg); } + 75% { + clip: rect(73px, 9999px, 90px, 0); + transform: skew(0.24deg); } + 80% { + clip: rect(93px, 9999px, 23px, 0); + transform: skew(0.31deg); } + 85% { + clip: rect(92px, 9999px, 65px, 0); + transform: skew(1deg); } + 90% { + clip: rect(65px, 9999px, 61px, 0); + transform: skew(0.13deg); } + 95% { + clip: rect(99px, 9999px, 17px, 0); + transform: skew(0.02deg); } + 100% { + clip: rect(99px, 9999px, 38px, 0); + transform: skew(0.23deg); } } + +@keyframes glitch-anim2 { + 0% { + clip: rect(50px, 9999px, 51px, 0); + transform: skew(0.2deg); } + 5% { + clip: rect(53px, 9999px, 26px, 0); + transform: skew(0.91deg); } + 10% { + clip: rect(43px, 9999px, 19px, 0); + transform: skew(0.7deg); } + 15% { + clip: rect(33px, 9999px, 74px, 0); + transform: skew(0.53deg); } + 20% { + clip: rect(47px, 9999px, 61px, 0); + transform: skew(0.08deg); } + 25% { + clip: rect(20px, 9999px, 31px, 0); + transform: skew(0.09deg); } + 30% { + clip: rect(55px, 9999px, 69px, 0); + transform: skew(0.68deg); } + 35% { + clip: rect(5px, 9999px, 43px, 0); + transform: skew(0.44deg); } + 40% { + clip: rect(13px, 9999px, 80px, 0); + transform: skew(0.73deg); } + 45% { + clip: rect(60px, 9999px, 58px, 0); + transform: skew(0.86deg); } + 50% { + clip: rect(52px, 9999px, 24px, 0); + transform: skew(0.12deg); } + 55% { + clip: rect(37px, 9999px, 41px, 0); + transform: skew(0.94deg); } + 60% { + clip: rect(31px, 9999px, 8px, 0); + transform: skew(0.75deg); } + 65% { + clip: rect(86px, 9999px, 51px, 0); + transform: skew(0.17deg); } + 70% { + clip: rect(41px, 9999px, 23px, 0); + transform: skew(0.47deg); } + 75% { + clip: rect(70px, 9999px, 14px, 0); + transform: skew(0.61deg); } + 80% { + clip: rect(32px, 9999px, 24px, 0); + transform: skew(0.43deg); } + 85% { + clip: rect(100px, 9999px, 69px, 0); + transform: skew(0.49deg); } + 90% { + clip: rect(45px, 9999px, 56px, 0); + transform: skew(0.47deg); } + 95% { + clip: rect(85px, 9999px, 95px, 0); + transform: skew(0.55deg); } + 100% { + clip: rect(85px, 9999px, 14px, 0); + transform: skew(0.41deg); } } + +@keyframes glitch-skew { + 0% { + transform: skew(4deg); } + 10% { + transform: skew(-3deg); } + 20% { + transform: skew(-4deg); } + 30% { + transform: skew(-4deg); } + 40% { + transform: skew(-3deg); } + 50% { + transform: skew(-2deg); } + 60% { + transform: skew(-4deg); } + 70% { + transform: skew(0deg); } + 80% { + transform: skew(5deg); } + 90% { + transform: skew(1deg); } + 100% { + transform: skew(4deg); } } |