Skip to content

Stop wide docs code blocks and tables from overflowing the page#162

Merged
thdxg merged 2 commits into
mainfrom
claude/docs-codeblock-layout-shift-17f52a
Jul 7, 2026
Merged

Stop wide docs code blocks and tables from overflowing the page#162
thdxg merged 2 commits into
mainfrom
claude/docs-codeblock-layout-shift-17f52a

Conversation

@thdxg

@thdxg thdxg commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Problem

The docs site had two independent horizontal-overflow bugs:

  1. Layout shift at mid-range widths (~769–1180px). .docs-shell is a flex item of the display:flex <body> column. With its default min-width: auto, flexbox refused to shrink it below its content floor (fixed 212px sidebar + gap + .docs-main's 760px max-width), so a page whose content filled the column pushed the whole shell — and the sticky nav — past the viewport. Narrow pages fit, wide ones didn't, so the nav jumped horizontally between pages.

  2. Mobile break. Markdown tables (in the Remote projects and CLI pages) had no CSS at all and rendered at their natural content width, blowing the page out ~138px past a 375px viewport. The code blocks were already fine — they scroll inside their own <pre>.

Fix

CSS-only, in website/src/tailwind.css:

  • .docs-shell — add width: 100%; min-width: 0; box-sizing: border-box so it's pinned to the viewport and .docs-main (already min-width: 0) can shrink. Wide code then scrolls inside its own <pre> (overflow-x: auto) instead of shifting the page.
  • .prose-docs tabledisplay: block; max-width: 100%; overflow-x: auto so a too-wide table scrolls within its own box like a code block, plus basic cell styling to match the docs' look.

Verification

Measured the DOM and screenshotted at 375, 900, 935, and 1440px:

  • No horizontal page overflow at any width (document.scrollWidth === viewport).
  • Wide code blocks and tables scroll inside their own boxes.
  • On wide screens the shell still centers at its 1180px max with .docs-main at 760px — no regression.

The built public/tailwind.css is a gitignored artifact regenerated by the build, so only the source CSS is committed.

The docs shell is a flex item of the flex-column <body>. With the
default min-width:auto it wouldn't shrink below its content floor (the
fixed sidebar plus .docs-main's max-width), so a page whose content
filled the column pushed the whole shell — and the sticky nav — past the
viewport. The nav shifted horizontally between a narrow page and a wide
one. Pin the shell to the viewport (width:100% + min-width:0) so
.docs-main shrinks and wide code scrolls inside its own pre.

Markdown tables had no styles at all and rendered at their natural
content width, overflowing the page on mobile. Make them scroll
horizontally within their own box like code blocks.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
macterm 1887851 Commit Preview URL

Branch Preview URL
Jul 07 2026, 06:34 PM

The content column used to hug the sidebar with all the slack on the
right. Make .docs-main a centered grid track so the 760px reading column
sits centered in the space to the right of the sidebar, with balanced
margins. Collapses to full width on mobile (single-column shell).
@thdxg thdxg merged commit a3c1de3 into main Jul 7, 2026
9 checks passed
@thdxg thdxg deleted the claude/docs-codeblock-layout-shift-17f52a branch July 7, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant