Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> <style> .content { display: flex; width: 100vw; height: 100vh; background-color: black; background-image: url("https://images.unsplash.com/photo-1489875347897-49f64b51c1f8?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjM4MDE5fQ&auto=format&fit=crop&w=1050&q=80"); background-repeat: no-repeat; background-position: center; background-size: cover; } .text { margin: auto; font-family: 'Montserrat', sans-serif; font-size: 120px; text-transform: uppercase; } .glitch { position: relative; color: white; mix-blend-mode: lighten; } .glitch:before, .glitch:after { content: attr(data-text); position: absolute; top: 0; width: 100%; background: black; clip: rect(0, 0, 0, 0); } .glitch:before { left: -1px; text-shadow: 1px 0 rgba(255, 0, 0, 0.7); } .glitch:after { left: 1px; text-shadow: -1px 0 rgba(0, 0, 255, 0.7); } .glitch:hover:before { text-shadow: 4px 0 rgba(255, 0, 0, 0.7); animation: glitch-loop-1 0.8s infinite ease-in-out alternate-reverse; } .glitch:hover:after { text-shadow: -5px 0 rgba(0, 0, 255, 0.7); animation: glitch-loop-2 0.8s infinite ease-in-out alternate-reverse; } @keyframes glitch-loop-1 { 0% { clip: rect(36px, 9999px, 9px, 0); } 25% { clip: rect(25px, 9999px, 99px, 0); } 50% { clip: rect(50px, 9999px, 102px, 0); } 75% { clip: rect(30px, 9999px, 92px, 0); } 100% { clip: rect(91px, 9999px, 98px, 0); } } @keyframes glitch-loop-2 { 0% { top: -1px; left: 1px; clip: rect(65px, 9999px, 119px, 0); } 25% { top: -6px; left: 4px; clip: rect(79px, 9999px, 19px, 0); } 50% { top: -3px; left: 2px; clip: rect(68px, 9999px, 11px, 0); } 75% { top: 0px; left: -4px; clip: rect(95px, 9999px, 53px, 0); } 100% { top: -1px; left: -1px; clip: rect(31px, 9999px, 149px, 0); } } </style> </head> <body> <div class="content"> <h1 class="text glitch is-glitching" data-text="Hover me!">Hover me!</h1> </div> </body> </html>