Skip to content
←  All case files

FIX-01Typical client request · rebuilt as a demo

Header menu breaks the page on phones

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

Open before ↗
Header menu breaks the page on phones: before the fix, 375px wideHeader menu breaks the page on phones: after the fix, 375px wideHeader menu breaks the page on phones: before the fix, 768px wideHeader menu breaks the page on phones: after the fix, 768px wideHeader menu breaks the page on phones: before the fix, 1280px wideHeader menu breaks the page on phones: after the fix, 1280px wide

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.

Next case · FIX-02PDF leaves a heading behind