← All case files





Header menu breaks the page on phones
On phones, the menu runs off the screen and the whole page slides sideways.






Cause
The logo, six links and a button all sat in one flex row with nowrap and no media query. At 375px that row needs about 760px, so the logo gets squashed and the nav pushes the page wider than the screen.
Fix
- .logo { font-weight: 800; }+ .logo { flex-shrink: 0; font-weight: 800; }+ @media (max-width: 860px) {+ .menu-btn { display: inline-grid; }+ .nav { display: none; position: absolute; inset: 100% 0 auto; flex-direction: column; }+ .site-header[data-open] .nav { display: flex; }+ }
The menu button is a real <button> with aria-expanded, so it works with a keyboard and a screen reader. I checked it at 375, 768 and 1280px, and the page no longer scrolls sideways.