Glitch Effect Button
Preview
Edit
Download
Run
Download Options
HTML File
Download as .html file
CSS File
Download as .css file
JavaScript File
Download as .js file
Combined HTML
All code in one HTML file
Project ZIP
All files in a ZIP archive
Cancel
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title> Buttons </title> </head> <body> <div class="container"> <div class="buttons-grid"> <div class="button-card"> <div class="button-title">Glitch Effect</div> <button class="btn-glitch" data-text="GLITCH">Glitch</button> </div> </div> </div> </body> </html>
CSS
* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem; } .container { max-width: 1200px; width: 100%; } .button-title { color: white; font-size: 1.1rem; margin-bottom: 1rem; font-weight: 600; } /* Button 10: Glitch */ .btn-glitch { background: #2c2c54; color: #00ff00; border: 1px solid #00ff00; padding: 15px 30px; border-radius: 5px; font-size: 16px; font-weight: 600; cursor: pointer; position: relative; font-family: 'Courier New', monospace; text-transform: uppercase; letter-spacing: 2px; } .btn-glitch:hover { animation: glitch 0.3s ease-in-out infinite; } @keyframes glitch { 0%, 100% { transform: translate(0); } 20% { transform: translate(-2px, 2px); } 40% { transform: translate(-2px, -2px); } 60% { transform: translate(2px, 2px); } 80% { transform: translate(2px, -2px); } } .btn-glitch:hover::before { content: attr(data-text); position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: #2c2c54; color: #ff0000; clip: rect(0, 900px, 0, 0); animation: glitch-anim 0.3s infinite linear alternate-reverse; } @keyframes glitch-anim { 0% { clip: rect(42px, 9999px, 44px, 0); } 25% { clip: rect(12px, 9999px, 59px, 0); } 50% { clip: rect(63px, 9999px, 27px, 0); } 75% { clip: rect(34px, 9999px, 71px, 0); } 100% { clip: rect(25px, 9999px, 98px, 0); } } @media (max-width: 768px) { .buttons-grid { grid-template-columns: 1fr; } h1 { font-size: 2rem; } }
JavaScript
// Add click feedback for all buttons document.querySelectorAll('button').forEach(button => { button.addEventListener('click', function() { // Create a temporary scale effect on click this.style.transform = 'scale(0.95)'; setTimeout(() => { this.style.transform = ''; }, 150); }); }); // Add extra interactivity to the magnetic button const magneticBtn = document.querySelector('.btn-magnetic'); magneticBtn.addEventListener('mousemove', function(e) { const rect = this.getBoundingClientRect(); const x = e.clientX - rect.left - rect.width / 2; const y = e.clientY - rect.top - rect.height / 2; this.style.transform = `translate(${x * 0.1}px, ${y * 0.1}px) scale(1.1)`; }); magneticBtn.addEventListener('mouseleave', function() { this.style.transform = ''; });
Output Preview
Desktop
Mobile
Fullscreen