Skip to main content

Html Css Dropdown Menu Codepen Apr 2026

/* adjust submenu arrow */ .submenu-arrow margin-left: auto; font-size: 0.7rem; transition: transform 0.2s;

<!-- Services dropdown (with nested submenu) --> <li class="nav-item"> <a href="#" class="nav-link"> ⚙️ Services <span class="dropdown-arrow">▼</span> </a> <ul class="dropdown-menu"> <li><a href="#"><span class="menu-icon">🎨</span> UI/UX Design</a></li> <li><a href="#"><span class="menu-icon">📈</span> Consulting</a></li> <!-- nested submenu item (dropdown inside dropdown) --> <li class="dropdown-submenu"> <a href="#"> <span class="menu-icon">⚡</span> Development <span class="submenu-arrow">›</span> </a> <ul class="dropdown-menu"> <li><a href="#">Frontend</a></li> <li><a href="#">Backend</a></li> <li><a href="#">Full Stack</a></li> <li><a href="#">DevOps</a></li> </ul> </li> <li><a href="#"><span class="menu-icon">🔍</span> SEO & Analytics</a></li> </ul> </li>

/* dropdown menu items */ .dropdown-menu li width: 100%;

.hero-content p color: #2c3e50; max-width: 550px; margin: 1rem auto 0; line-height: 1.5; html css dropdown menu codepen

.dropdown-submenu:hover .submenu-arrow transform: translateX(3px);

body background: linear-gradient(145deg, #e9f0fc 0%, #d9e2ef 100%); font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 2rem;

.badge-note background: #1e3a5f10; display: inline-block; border-radius: 40px; padding: 0.2rem 1rem; font-size: 0.8rem; font-weight: 500; color: #2c5a7a; margin-top: 1rem; /* adjust submenu arrow */

/* show dropdown on hover */ .nav-item:hover > .dropdown-menu opacity: 1; visibility: visible; transform: translateY(0); pointer-events: auto;

/* responsive: for smaller screens ensure dropdown appears nicely */ @media (max-width: 780px) .nav-menu padding: 0.5rem; border-radius: 2rem; .nav-link padding: 0.6rem 1rem; font-size: 0.9rem; .dropdown-menu min-width: 190px;

/* right side fallback for submenu on edge */ .dropdown-submenu:hover > .dropdown-menu pointer-events: auto; transition: transform 0.2s

<div class="hero-content"> <h2>Pure CSS Dropdown Experience</h2> <p>Hover over any menu item with a chevron ▼ — elegant submenus appear smoothly. <br> Includes nested dropdown inside "Services → Development". Fully responsive and keyboard accessible via focus.</p> <div class="badge-note"> 🧪 CSS only • No JavaScript • Clean transitions </div> </div> </div> <footer> ⚡ Modern dropdown menu | Hover to expand | Nested support | Pure HTML/CSS </footer>

/* ----- DROPDOWN MENU STYLES (multi-level but flat design) ----- */ .dropdown-menu position: absolute; top: calc(100% + 0.7rem); left: 0; min-width: 220px; background: #ffffff; border-radius: 1.5rem; padding: 0.7rem 0; list-style: none; box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0,0,0,0.02); opacity: 0; visibility: hidden; transform: translateY(-12px); transition: all 0.28s cubic-bezier(0.2, 0.9, 0.4, 1.1); pointer-events: none; z-index: 200; backdrop-filter: blur(0px);

/* right-aligned dropdown (for last items if needed) — but we handle overflow */ .nav-item:last-child .dropdown-menu left: auto; right: 0;

/* optional icon inside dropdown */ .menu-icon font-size: 1.1rem; display: inline-block; width: 1.4rem; text-align: center;