brokeinprod
brokeinprod
Theme

Debugging

My Homepage Was Cut Off ¾ Across on Mobile. It Took Three Fixes to Get It Back.

Our homepage truncated ¾ across on mobile. Three stacked bugs: a 7364px ticker track, an implicit grid column, and a stale build masking the fix.

December 3, 2026

One bug that takes an hour is a bad night. Three bugs stacked, where fixing each one reveals the next and the last one makes the first two look like they did not work, is a story.

Start here: A page that renders truncated on mobile with dead space to the right is usually not one bug. Check three layers in order. (1) Something wider than the viewport is setting the page's layout width. Find it with the console width-finder below, then contain it with html { overflow-x: clip } (not hidden). (2) A grid with only lg:grid-cols-* leaves mobile on an implicit auto track that sizes to its content. Add an explicit grid-cols-1 base. (3) If a fix "doesn't work," check whether the rendered DOM contains your change at all. A stale .next build will serve last hour's CSS while you debug this hour's theory.

The setup

A neon-heavy developer publication homepage: marquee ticker across the top, a hero grid with a glowing code window whose long lines are the point, pillar cards, and an article list. On desktop it rendered correctly. On a phone, the page rendered truncated about three-quarters of the way across, with dead space down the right edge. Only the homepage. Every other page was fine.

The symptom, layer by layer

Layer 1: the page itself was too wide. The browser-console width-finder names overflow offenders directly:

 
 
[...document.querySelectorAll('*')]
  .filter(el => el.offsetWidth > document.documentElement.clientWidth)
  .forEach(el => console.log(el, el.offsetWidth))

It pointed at the ticker's marquee track: 7364px wide. The ticker had overflow: hidden, which is why it looked contained. But hidden clips paint, not layout width. The too-wide track still propagated its width up through the unconstrained body column and set the page's scroll width. The whole viewport was scaled against a 7364px page.

Fix 1 (repo-verified, globals.css):

 
 
html {
  overflow-x: clip;
}

clip contains runaway layout width at the root without creating a scroll container. That matters, because overflow-x: hidden on html or body would have silently killed position: sticky on the header. Same property family, precisely chosen.

Layer 2: now elements were clipped instead. Page width fixed, but the hero code window and headline ran off-screen, now cut off rather than scrolling. The hero was a bare grid with only lg:grid-cols-[1.05fr_0.95fr]. Below lg it sat on an implicit auto column, which sizes to the child's intrinsic content width with no bound. The code window's long unwrapped lines set a huge track width, and the child's min-width: 0 could not help, because the track definition was the offender, not the child.

Fix 2 (repo-verified, app/page.tsx and globals.css): explicit mobile bases on the grids, since an explicit 1fr track is container-bounded:

 
 
<div className="grid grid-cols-1 items-center gap-12 … lg:grid-cols-[1.05fr_0.95fr]">

Plus the companion constraints so long code lines scroll inside the window:

 
 
.codewin {
  min-width: 0;        /* allow shrink below intrinsic content width */
  max-width: 100%;     /* never exceed the grid column / viewport */
}
/* with pre { overflow-x: auto } — the correct mobile code-block behavior */

Layer 3: the fix "didn't work." Reload: still broken. The theory spiral began, until inspecting the live DOM showed the rendered markup did not contain grid-cols-1 at all. The source did. The dev server was serving a stale compile.

Fix 3:

 
 
rm -rf .next   # then restart, hard reload (or Incognito)

This is the layer that cost two extra rounds, because it invalidates your evidence about the other layers. You evaluate fixes 1 and 2 against a page that contains neither.

The diagnosis, compressed

Three independent facts that compound:

  1. overflow: hidden and clip clip paint, not layout width. A too-wide child in an unconstrained column still stretches the page. Root-level overflow-x: clip is the page guard; hidden is the sticky-killer.
  2. Implicit auto grid tracks size to content; explicit tracks are container-bounded. A Tailwind grid that only defines columns at lg: has no mobile column definition at all. When a wide child clips inside a grid, suspect the track, not the child.
  3. When the rendered DOM does not match your source, debug the build, not the code. Every minute spent writing more CSS against a stale compile is a minute spent making the layer 1 and layer 2 conclusions wrong.

And the lesson that made layer 1 findable at all: the diagnostic beats the hypothesis. The prime suspect was the code window, big, wide, and obviously overflow-shaped. The width-finder said ticker, 7364px. Run the tool before trusting the guess.

The inverse case, for symmetry

Weeks earlier, the same property solved the opposite problem on the same site. Decorative HUD corner brackets drawn 1px outside their boxes were vanishing under overflow: hidden. The fix there was overflow: clip with overflow-clip-margin: 2px, which preserves wanted overflow immediately past the border-box, still without a scroll container. clip cuts both ways: contain runaway width at the root, or grant decorative pixels a margin at the component. Know which direction you need.

DevTools emulation reported a viewport width the real phone did not (430 versus 621 in one reading). Emulation found the bug. The physical device was ground truth for declaring it fixed. Both, always, in that order.


Layered bugs punish sequential thinking. The width-finder, the explicit track, and rm -rf .next are each thirty-second moves. The hour goes to not knowing which layer you are looking at.

FAQ

Why not overflow-x: hidden on body, as most Stack Overflow answers say? It usually "works," and it quietly breaks position: sticky anywhere in the page, because hidden establishes a scroll container. clip does the containment without the container. If you have a sticky header and a hidden-overflow body, this is why the header stopped sticking.

Where else does the implicit-auto-track trap show up? Any responsive Tailwind grid written desktop-first. grid lg:grid-cols-3 looks complete and is not; mobile has no track definition. The fix is habit-sized: every grid gets an explicit base (grid-cols-1) before any breakpoint variants.

How do I know it is a stale build and not my CSS? Inspect the live element and look for the class or rule you added. Present but ineffective means a CSS problem (specificity, cascade). Absent means a build problem. The check takes ten seconds, and it is the fork in the whole investigation.

Does min-width: 0 on the child ever matter, then? Yes. Once the track is explicit (1fr), grid and flex children still default to min-width: auto, which cannot shrink below content. min-width: 0 is what lets the code window compress so its pre can scroll internally. Track fix and child fix are companions, not alternatives.

Further reading

Keep reading

Newsletter

New posts in your inbox. No spam — unsubscribe anytime.

Occasional emails when we publish something worth your time. Unsubscribe anytime.

More about what you'll get on the newsletter page.

THEME
↑↓ navigate↵ openesc close