Highly Styled Dropdown Menu - VexaX
Run Code
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>Highly Styled Dropdown Menu</title> <style> body { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background: linear-gradient(to right, #ff7e5f, #feb47b); margin: 0; } .dropdown { position: relative; display: inline-block; } .dropdown-button { background-color: #4CAF50; color: white; padding: 16px; font-size: 16px; border: none; cursor: pointer; border-radius: 8px; transition: background-color 0.3s; box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); } .dropdown-button:hover { background-color: #45a049; } .dropdown-content { display: none; position: absolute; background-color: #f9f9f9; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1; border-radius: 8px; animation: fadeIn 0.5s; } @keyframes fadeIn { from {opacity: 0;} to {opacity: 1;} } .dropdown-content a { color: black; padding: 12px 16px; text-decoration: none; display: block; border-radius: 8px; transition: background-color 0.3s, transform 0.2s; } .dropdown-content a:hover { background-color: #f1f1f1; transform: scale(1.05); } .dropdown-content a i { margin-right: 8px; } </style> </head> <body> <div class="dropdown"> <button class="dropdown-button">Menu ⬇️</button> <div class="dropdown-content"> <a href="#"><i class="fas fa-home"></i> Home 🏠</a> <a href="#"><i class="fas fa-user"></i> Profile 👤</a> <a href="#"><i class="fas fa-cog"></i> Settings ⚙️</a> <a href="#"><i class="fas fa-sign-out-alt"></i> Logout 🚪</a> </div> </div> <script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script> <script> document.addEventListener('DOMContentLoaded', () => { const dropdownButton = document.querySelector('.dropdown-button'); const dropdownContent = document.querySelector('.dropdown-content'); dropdownButton.addEventListener('click', () => { dropdownContent.style.display = dropdownContent.style.display === 'block' ? 'none' : 'block'; }); window.addEventListener('click', (e) => { if (!e.target.matches('.dropdown-button')) { if (dropdownContent.style.display === 'block') { dropdownContent.style.display = 'none'; } } }); }); </script> </body> </html>