Toggle navigation
☰
HTML
CSS
Scripting
Database
<!doctype html> <title>Example</title> <style> body { display: flex; justify-content: center; align-items: flex-start; padding-top: 100px; height: 100vh; margin: 0; font-family: sans-serif; background-color: #f0f0f0; } .dropdown-container { position: relative; display: inline-block; } .dropdown-btn { background-color: #007bff; color: white; padding: 12px 20px; font-size: 1rem; border: none; border-radius: 4px; cursor: pointer; } .dropdown-menu { position: absolute; top: 100%; left: 0; margin-top: 10px; background-color: white; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); border-radius: 4px; padding: 8px 0; /* Initially hidden and scaled down */ opacity: 0; visibility: hidden; transform: translateY(-10px) scale(0.95); transform-origin: top; transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s; } .dropdown-menu a { color: black; padding: 12px 16px; text-decoration: none; display: block; } .dropdown-menu a:hover { background-color: #f1f1f1; } /* Hovering on the container reveals the menu */ .dropdown-container:hover .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0) scale(1); } @media (prefers-reduced-motion: reduce) { .dropdown-menu { /* Removes the slide/scale effect, keeping only the opacity fade */ transition: opacity 0.2s ease, visibility 0.2s; transform: none; } } </style> <div class="dropdown-container"> <button class="dropdown-btn">Features â–¼</button> <div class="dropdown-menu"> <a href="#">Analytics</a> <a href="#">Reporting</a> <a href="#">Integrations</a> </div> </div>