Build a Responsive Navigation Bar With Mega Menu and Mobile Drawer in HTML
A complete single-file site header with a hover, click and arrow-key mega menu on desktop and an animated hamburger drawer with accordions on small screens.
You getone complete HTML file in a single code block, then 3 short ideas to extend it.
The prompt
Act as a senior front-end designer who writes clean, accessible vanilla HTML, CSS and JavaScript.
Build a responsive site header for Harbor & Pine, a member-owned outdoor co-op: a desktop mega menu, a mobile slide-in drawer, and a short hero section below it.
Gear, Trips and Learn open mega panels with three titled columns of links (name plus one-line description) and a dark feature card. Journal and Stores are plain links. Sign in and a Join the co-op button sit on the right.
Rules:
1. From 900px up, panels open on hover with short delays, toggle on click, and close on outside click, Escape or tabbing away. Keep aria-expanded in sync.
2. Keyboard: Left/Right move between top items, Down opens a panel and focuses its first link, Up/Down step through links, Left/Right jump between columns, Escape closes and returns focus.
3. Below 900px, a hamburger that morphs into an X opens a drawer under the header with accordion sections, a dim backdrop, trapped focus, Escape to close, and auto-close on resize to desktop.
4. Cream background, forest green, amber focus rings, system fonts, 44px touch targets. It must look right from 360 to 1280px.
5. Honor prefers-reduced-motion. Use no external files, storage or forms. Links show the chosen item in a status line instead of navigating.
Output format: one complete HTML file in a single code block, then 3 short ideas to extend it.Example output
Tips and common edits
Why this works
- One 900px breakpoint with separate desktop and drawer markup keeps both layouts simple and predictable at every width.
- Spelling out each key (arrows, Home, End, Esc) and syncing aria-expanded makes the keyboard behaviour work on the first try.
- Opening on hover with short delays, plus click-to-pin, stops panels from flickering when the mouse crosses gaps.
Paste into ChatGPT, Claude or Gemini. Save the code as an .html file and open it in a browser, or use the chat's preview/canvas. Resize the window to test both the desktop and drawer layouts.
Common edits
- Swap the brand, menu labels and link data in the NAV array to match your own site's sections.
- Change the breakpoint from 900px or the palette variables to fit a different layout or brand.
Prompt details
- By
- Prompts-GPT editors
- Published
Keep exploring
More like this
Build a Light/Dark Mode Toggle Demo Page with Smooth Theme Switching
A single HTML page with a polished light/dark theme switch built on CSS custom properties that defaults to the system theme, honors reduced motion, and uses no storage.
Build a Multi-Step Onboarding Wizard with Stepper and Inline Validation
A four-step onboarding wizard in one HTML file, with a clickable stepper, progress bar, inline validation, a review screen, and keyboard and swipe navigation.
Build a Playful Animated 404 Error Page with SVG Art and Site Search
A complete single-file 404 page with an original animated hot-air balloon SVG, a live-filtering search box and helpful recovery links that respect reduced motion.
Build a Responsive Three-Tier Pricing Section with Monthly/Yearly Toggle
A single HTML file with three pricing cards, a working billing switch that recalculates prices, a highlighted recommended plan and accessible feature checkmarks.
Build an Accessible Modal, Toast and Tooltip Showcase in One HTML File
You get a single HTML page with a modal dialog, toast notifications and tooltips. All three use focus trapping, Escape handling, correct ARIA roles and live-region announcements.
Design an Accessible Settings Page with Toggles, Segmented Controls and Sliders
A ready-to-paste prompt that builds a polished single-file settings page with custom accessible toggles, segmented controls and sliders that update a live reading preview.
- Build a Button and Form Field States Reference Sheet in a Single HTML File
- Build a Color Blindness Simulator That Previews a Palette on a Dashboard Card
- Build a Drag-to-Arrange Brand Mood Board with Color, Texture and Type Tiles
- Build a Draggable Color Harmony Wheel With Live UI Preview in One HTML File
- Build a Live Accessible Color Palette Builder with a WCAG Contrast Matrix
- Build a SaaS Landing Page Hero with a CSS-Drawn Product Mockup