Classic Purple Dropdown - 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>Classic Purple Dropdown</title> <style> body { font-family: 'Arial', sans-serif; background: #e8d3f1; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .dropdown { position: relative; display: inline-block; } .dropdown-toggle { background-image: linear-gradient(to top left, rgba(0, 0, 0, .2), rgba(0, 0, 0, .2) 30%, rgba(0, 0, 0, 0)); box-shadow: inset 2px 2px 3px rgba(255, 255, 255, .6), inset -2px -2px 3px rgba(0, 0, 0, .6); padding: 15px 30px; border-radius: 30px; cursor: pointer; color: #fff; background: linear-gradient(45deg, #7b2ff7, #f107a3); transition: all 0.3s ease; display: flex; align-items: center; gap: 10px; } .dropdown-toggle:hover { box-shadow: inset 3px 3px 5px rgba(255, 255, 255, .8), inset -3px -3px 5px rgba(0, 0, 0, .8); } .dropdown-menu { display: none; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); background: linear-gradient(to top left, rgba(0, 0, 0, .2), rgba(0, 0, 0, .2) 30%, rgba(0, 0, 0, 0)); box-shadow: inset 2px 2px 3px rgba(255, 255, 255, .6), inset -2px -2px 3px rgba(0, 0, 0, .6); border-radius: 20px; overflow: hidden; z-index: 1; animation: fadeIn 0.3s ease; } .dropdown-menu.show { display: block; } .dropdown-menu a { display: block; padding: 15px 20px; text-decoration: none; color: #333; transition: all 0.3s ease; position: relative; } .dropdown-menu a:hover { background: rgba(255, 255, 255, 0.3); color: #000; } .dropdown-menu a::before { content: ''; position: absolute; top: 0; left: 0; height: 100%; width: 5px; border-radius: 0 5px 5px 0; transition: width 0.3s ease; width: 0; } .dropdown-menu a:hover::before { width: 100%; } @keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } .dropdown-icon { font-size: 20px; color: #fff; transition: transform 0.3s ease; } .dropdown-menu.show .dropdown-icon { transform: rotate(180deg); } </style> </head> <body> <div class="dropdown"> <div class="dropdown-toggle"> <span>Classic Purple</span> <i class="dropdown-icon">▼</i> </div> <div class="dropdown-menu"> <a href="#">Home</a> <a href="#">About</a> <a href="#">Services</a> <a href="#">Contact</a> </div> </div> <script> document.addEventListener('DOMContentLoaded', function () { const dropdownToggle = document.querySelector('.dropdown-toggle'); const dropdownMenu = document.querySelector('.dropdown-menu'); const dropdownIcon = document.querySelector('.dropdown-icon'); dropdownToggle.addEventListener('click', function () { dropdownMenu.classList.toggle('show'); dropdownIcon.classList.toggle('rotate'); }); document.addEventListener('click', function (e) { if (!dropdownToggle.contains(e.target) && !dropdownMenu.contains(e.target)) { dropdownMenu.classList.remove('show'); dropdownIcon.classList.remove('rotate'); } }); }); </script> </body> </html>