Unique Dropdown Menu - 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>Unique Dropdown Menu</title> <style> body { font-family: 'Arial', sans-serif; background-color: #f0f2f5; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .dropdown { position: relative; display: inline-block; } .dropdown-toggle { background-color: #6200ea; color: white; padding: 12px 24px; font-size: 16px; border: none; border-radius: 8px; cursor: pointer; display: flex; align-items: center; transition: background-color 0.3s ease; } .dropdown-toggle:hover { background-color: #3700b3; } .dropdown-toggle:focus { outline: none; } .dropdown-toggle .icon { margin-left: 10px; transition: transform 0.3s ease; } .dropdown-toggle .icon.rotate { transform: rotate(180deg); } .dropdown-menu { display: none; position: absolute; top: 100%; left: 0; background-color: white; border: 1px solid #ddd; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); border-radius: 8px; overflow: hidden; transition: max-height 0.3s ease, opacity 0.3s ease; max-height: 0; opacity: 0; z-index: 1000; } .dropdown-menu.show { display: block; max-height: 400px; opacity: 1; } .dropdown-menu-item { padding: 12px 24px; display: flex; align-items: center; transition: background-color 0.3s ease; cursor: pointer; } .dropdown-menu-item:hover { background-color: #f0f2f5; } .dropdown-menu-item .icon { margin-right: 10px; font-size: 18px; } .dropdown-menu-item .text { font-size: 16px; } .dropdown-menu-item .emoji { margin-left: auto; font-size: 20px; } </style> </head> <body> <div class="dropdown"> <button class="dropdown-toggle"> Menu <span class="icon">▼</span> </button> <div class="dropdown-menu"> <div class="dropdown-menu-item"> <span class="icon">🏠</span> <span class="text">Home</span> <span class="emoji">😊</span> </div> <div class="dropdown-menu-item"> <span class="icon">🔍</span> <span class="text">Search</span> <span class="emoji">😎</span> </div> <div class="dropdown-menu-item"> <span class="icon">📧</span> <span class="text">Contact</span> <span class="emoji">📧</span> </div> <div class="dropdown-menu-item"> <span class="icon">⚙️</span> <span class="text">Settings</span> <span class="emoji">⚙️</span> </div> </div> </div> <script> document.querySelector('.dropdown-toggle').addEventListener('click', function() { const dropdownMenu = document.querySelector('.dropdown-menu'); const dropdownIcon = document.querySelector('.dropdown-toggle .icon'); dropdownMenu.classList.toggle('show'); dropdownIcon.classList.toggle('rotate'); }); document.addEventListener('click', function(event) { const dropdown = document.querySelector('.dropdown'); const dropdownMenu = document.querySelector('.dropdown-menu'); const dropdownIcon = document.querySelector('.dropdown-toggle .icon'); if (!dropdown.contains(event.target)) { dropdownMenu.classList.remove('show'); dropdownIcon.classList.remove('rotate'); } }); </script> </body> </html>