Dev Helpers
← Back

Grouped mega menu

Grouped mega menu in responsive HTML and CSS. Try the preview at phone, tablet, and desktop widths.

Open this example in the interactive library

Live preview

Source code

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title>Grouped mega menu</title>
  <style>
    * { box-sizing: border-box; }
    body { margin: 0; padding: clamp(12px,4vw,44px); background: #f6f2ea; color: #252927; font: 16px/1.5 system-ui,sans-serif; }
    main { max-width: 68rem; margin: auto; min-width: 0; overflow-wrap: anywhere; }
    fieldset,label,.stack,.box,input { min-width:0; }
    h1,h2,h3,p,figure,dl { margin: 0; }
    h1 { font: 500 clamp(2rem,6vw,4.75rem)/1.02 Georgia,serif; letter-spacing:-.045em; }
    h2 { font: 500 clamp(1.4rem,3vw,2.4rem)/1.12 Georgia,serif; }
    h3 { font-size: 1.05rem; }
    a { color: #713b24; text-underline-offset: .18em; }
    a,button,summary,label { touch-action: manipulation; }
    button, input, select, textarea { font: inherit; max-width:100%; }
    button,.action { display:inline-block; padding:.55rem .85rem; background:#27453f; color:white; border:0; border-radius:.3rem; cursor:pointer; text-decoration:none; }
    input:not([type=checkbox],[type=radio],[type=range],[type=color]),select,textarea { border:1px solid #878d82; border-radius:.25rem; padding:.55rem; background:white; color:#202822; }
    :focus-visible { outline:3px solid #a34720; outline-offset:3px; }
    details { padding:.7rem 0; border-bottom:1px solid #bcbcaf; }
    summary { cursor:pointer; font-weight:650; }
    dt,legend { font-weight:700; }
    dd { margin:0; }
    .stack,.grid,.split { display:grid; gap:1rem; }
    .row { display:flex; gap:.75rem; flex-wrap:wrap; align-items:center; }
    .grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,12rem),1fr)); }
    .box { border:1px solid #c9c8bc; background:#fffdf8; padding:clamp(.85rem,2vw,1.4rem); }
    .ink { background:#243d37; color:#fffaf1; padding:clamp(1rem,4vw,3rem); }
    .ink a { color:#fff4de; }
    .kicker { color:#805033; font:700 .78rem/1.5 ui-monospace,monospace; letter-spacing:.08em; text-transform:uppercase; }
    .ink .kicker { color:#efbd98; }
    .pill { display:inline-block; border:1px solid currentColor; border-radius:2rem; padding:.15rem .65rem; font-size:.84rem; }
    pre { overflow:auto; max-width:100%; padding:1rem; background:#213831; color:white; }
    table { border-collapse:collapse; width:100%; }
    th,td { padding:.55rem; border-bottom:1px solid #bcbcaf; text-align:left; }
    progress,meter { max-width:100%; }
    :where(.split,.grid)>* { min-width:0; }
    @media(min-width:44rem) { .split { grid-template-columns:repeat(2,minmax(0,1fr)); align-items:start; } }
    @media(prefers-reduced-motion:reduce) { * { scroll-behavior:auto !important; } }
  </style>
  
</head>
<body><main><div class="stack">
  <details>
    <summary>Explore departments</summary>
    <div class="split">
      <div class="stack">
        <h2>Studio</h2>
        <a href="#design">Design</a>
      </div>
      <div class="stack">
        <h2>Support</h2>
        <a href="#help">Help</a>
      </div>
    </div>
  </details>
  <section id="design" class="box stack">
    <h2>Design</h2>
    <p>See the design team.</p>
  </section>
  <section id="help" class="box stack">
    <h2>Help</h2>
    <p>Browse support articles.</p>
  </section>
</div></main></body>
</html>