Skip to content

Fix horizontal scrolling on blog posts - #113

Merged
kixelated merged 1 commit into
mainfrom
claude/blog-horizontal-scroll-fix-15cd72
Jul 30, 2026
Merged

Fix horizontal scrolling on blog posts#113
kixelated merged 1 commit into
mainfrom
claude/blog-horizontal-scroll-fix-15cd72

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Blog posts scrolled horizontally, most visibly on mobile.

Code blocks were the suspected cause, and they were part of it — but sweeping all 25 pages at 320/375/768/1280px turned up four independent causes.

What changed

Code blocks<pre> already had overflow-x: auto from the prose plugin, so the interesting question was why it wasn't working. The layout wrapper and <article> are flex items, which default to min-width: auto: refuse to shrink below the content's intrinsic width. The wide <pre> therefore widened the whole page instead of scrolling itself. Adding min-w-0 to both in global.astro is what actually makes the existing overflow rule take effect.

Tables — no scroll container, so a wide table (the congestion-control table in replacing-webrtc) pushed the page out. Now display: block + overflow-x: auto.

Long inline tokens — unbreakable strings like the inline code relay.cloudflare.mediaoverquic.com overflowed their paragraph. Added break-words.

A hardcoded YouTube embedfirst-cdn.mdx used <iframe width="560"> with no responsive cap. This was the single largest overflow (217px) and was invisible to the code-block theory. Replaced the fixed width/height attributes with max-width: 100% plus aspect-ratio: 16 / 9.

Notes for review

  • Tables use width: 100%, not width: max-content. My first attempt used the common GitHub-style max-content, which scrolls correctly but shrank desktop tables from 864px to 429px. width: 100% scrolls on mobile and preserves the existing full-width desktop appearance.
  • .markdown table is deliberately (0,1,1) specificity so it beats the prose plugin's .prose :where(table) (0,1,0) regardless of how the layers end up ordered.
  • The table and iframe rules are scoped to .markdown, so future posts are covered automatically.

Verification

Measured in-browser rather than eyeballed:

  • Zero overflow (scrollWidth - clientWidth) across all 25 pages × 4 viewport widths, ignoring elements legitimately clipped by a scroll ancestor.
  • No desktop regression — table columns stay aligned under display: block and tables remain 832px wide; the YouTube embed still renders 560×315 on desktop and 311×175 on mobile, 16:9 preserved at both.
  • bunx biome check and bun run build pass. (Biome reports one pre-existing config-migration info, unrelated to this change.)

bunx astro check was skipped — it wanted to install @astrojs/check, and I didn't want to add a dependency uninvited.

(written by Opus 5)

Blog posts scrolled horizontally, most visibly on mobile. Sweeping all 25
pages at 320/375/768/1280px turned up four independent causes:

- Code blocks: <pre> already had `overflow-x: auto` from the prose plugin,
  but the layout wrapper and <article> are flex items, which default to
  `min-width: auto` — i.e. refuse to shrink below their content's intrinsic
  width. The wide <pre> therefore widened the page instead of scrolling
  itself. `min-w-0` on both is what makes the existing overflow rule work.

- Tables: no scroll container, so a wide table (e.g. the congestion control
  table in replacing-webrtc) pushed the page out. Now `display: block` +
  `overflow-x: auto`. Kept at `width: 100%` rather than the more common
  `width: max-content` so tables stay full-width on desktop as before.

- Long inline tokens: unbreakable strings like the inline code
  `relay.cloudflare.mediaoverquic.com` overflowed their paragraph.
  Added `break-words`.

- A hardcoded YouTube embed in first-cdn.mdx used `width="560"` with no
  responsive cap — the single largest overflow at 217px. Swapped the fixed
  width/height attributes for `max-width: 100%` plus `aspect-ratio: 16 / 9`.

The table and iframe rules are scoped to `.markdown` so future posts are
covered. `.markdown table` is deliberately (0,1,1) specificity so it beats
the prose plugin's `.prose :where(table)` (0,1,0) regardless of layer order.

Verified in-browser: zero overflow across all 25 pages x 4 viewport widths;
table columns stay aligned under `display: block` and remain 832px wide on
desktop; the YouTube embed still renders 560x315 on desktop and 311x175 on
mobile with 16:9 preserved.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @kixelated, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@kixelated
kixelated merged commit 0878e02 into main Jul 30, 2026
2 checks passed
@kixelated
kixelated deleted the claude/blog-horizontal-scroll-fix-15cd72 branch July 30, 2026 18:01
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 56b93a33-5528-495e-b743-737d05ce4d8c

📥 Commits

Reviewing files that changed from the base of the PR and between 2b1171a and f34b7c5.

📒 Files selected for processing (3)
  • src/layouts/global.astro
  • src/layouts/global.css
  • src/pages/blog/first-cdn.mdx

Walkthrough

Updated the global layout to add min-w-0 to the content container and article. Extended markdown styles to wrap long URLs and inline code, enable horizontal scrolling for tables, and constrain iframe widths. Updated the first CDN blog post’s YouTube embed to use responsive inline sizing with a 16:9 aspect ratio.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: fixing horizontal scrolling on blog posts.
Description check ✅ Passed The description directly explains the overflow fixes and matches the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/blog-horizontal-scroll-fix-15cd72

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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