Glassmorphism Tabs - MeggiTools
Run
Toggle Theme
Share Link
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Glassmorphism Tabs</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"> <style> body { margin: 0; font-family: Arial, sans-serif; background: linear-gradient(to right, rgba(0, 128, 255, 0.5), rgba(255, 0, 150, 0.5)); height: 100vh; display: flex; justify-content: center; align-items: center; } .tabs-container { width: 80%; max-width: 600px; background: rgba(255, 255, 255, 0.2); border-radius: 15px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); padding: 20px; } .tabs-header { display: flex; border-bottom: 2px solid rgba(255, 255, 255, 0.3); margin-bottom: 10px; } .tab-button { flex: 1; padding: 15px; text-align: center; background: rgba(255, 255, 255, 0.3); border: none; border-bottom: 2px solid transparent; color: #fff; cursor: pointer; transition: background 0.3s, color 0.3s, border-bottom 0.3s; font-size: 16px; display: flex; align-items: center; justify-content: center; } .tab-button:hover, .tab-button.active { background: rgba(255, 255, 255, 0.4); color: #3498db; border-bottom: 2px solid #3498db; } .tab-content { display: none; animation: fadeIn 0.5s ease; } .tab-content.active { display: block; } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } .tab-content p { padding: 15px; margin: 0; background: rgba(255, 255, 255, 0.3); border-radius: 10px; } </style> </head> <body> <div class="tabs-container"> <div class="tabs-header"> <button class="tab-button active" data-tab="tab1"><i class="fas fa-home"></i> Home</button> <button class="tab-button" data-tab="tab2"><i class="fas fa-info-circle"></i> About</button> <button class="tab-button" data-tab="tab3"><i class="fas fa-envelope"></i> Contact</button> </div> <div class="tab-content active" id="tab1"> <p>Welcome to the Home tab. This is the content for the Home section.</p> </div> <div class="tab-content" id="tab2"> <p>Welcome to the About tab. This is the content for the About section.</p> </div> <div class="tab-content" id="tab3"> <p>Welcome to the Contact tab. This is the content for the Contact section.</p> </div> </div> <script> document.querySelectorAll('.tab-button').forEach(button => { button.addEventListener('click', () => { // Deactivate all buttons and hide all content document.querySelectorAll('.tab-button').forEach(btn => btn.classList.remove('active')); document.querySelectorAll('.tab-content').forEach(content => content.classList.remove('active')); // Activate the clicked button and corresponding content button.classList.add('active'); const tabId = button.getAttribute('data-tab'); document.getElementById(tabId).classList.add('active'); }); }); </script> </body> </html>