AGENT SKILL

horizontal-scroll-html-vs-body

Android Chrome ignores overflow-x:hidden on <body> if <html> still allows it — clip the root, not just the body, to kill phantom horizontal scroll

License 许可
MIT
最近更新
2026-11-14
Stars
★ 18
Forks
6

01 前言 Front Matter

name
horizontal-scroll-html-vs-body
metadata
{ "short-description": "Phantom horizontal scroll on Android — fix lives on <html>, not <body>" }
description
Android Chrome ignores overflow-x:hidden on <body> if <html> still allows it — clip the root, not just the body, to kill phantom horizontal scroll

02 资源文件 1

03 SKILL.md 正文

Horizontal Scroll — html vs body

What

A page renders cleanly on desktop and iOS Safari but on Android Chrome the user can drag the page left/right ("phantom horizontal scroll") even though nothing visible extends past the viewport. The most common reason is that overflow-x: hidden was placed on <body> but not on the <html> root.

Why this is browser-specific

When a descendant element briefly exceeds viewport width — an absolutely positioned dropdown with a fixed w-XX value, an off-screen carousel slide, an image without max-width: 100%, a transformed element, an inset-x-… container — the overflow propagates up to the initial containing block, which is the <html> element, not <body>.

Browser Honors body { overflow-x: hidden } alone Result
Chrome desktop Yes No phantom scroll
Firefox / Edge desktop Yes No phantom scroll
Safari iOS Yes (usually) No phantom scroll
Chrome Android No html scrolls horizontally

This bites mobile-heavy sites first because dev usually QAs on desktop.

When to suspect this

  • "Site moves left/right when I swipe but I don't see anything wider"
  • Only on Android, not iPhone, not desktop
  • Affects ALL pages of a layout, not just one (points at root layout, not page-specific)
  • Browser devtools "outline every element" trick reveals no visibly overflowing element

Fix

One line: add overflow-x: hidden to the <html> element. With Tailwind in an Astro/Next.js/Svelte layout that's literally:

- <html lang="es" class="scroll-smooth dark">
+ <html lang="es" class="scroll-smooth dark overflow-x-hidden">

In plain CSS:

html, body {
  overflow-x: hidden;
  /* don't forget overscroll-behavior-x: none if pull-to-refresh-x triggers */
}

Diagnostic

  1. Open the page in Android Chrome devtools (chrome://inspect from desktop).
  2. In Elements → Computed, select the <html> element. Look for overflow-x.
  3. If it's visible (the default) and <body> has hidden, you have this bug.
  4. Inject document.documentElement.style.overflowX = 'hidden' in the console — the scroll disappears? Confirmed.

Anti-patterns

  • Adding overflow: hidden (without the -x) — kills vertical scroll too. The page becomes a fixed-height card.
  • Adding width: 100vw to body — on iOS Safari, 100vw includes the scrollbar area on some configs, so the body itself becomes wider than the viewport. Stick to overflow-x: hidden on both html and body.
  • Trying to track down "what's overflowing" before applying the root-level clip. The clip is cheap and the failure mode (silently hiding off-canvas content) is rare in practice for well-built layouts.

Lessons Learned

<!-- Date · Symptom · Element that was overflowing (post-mortem grep) · Fix applied -->

04 同仓库更多 Skills

CarlosCaPe
CarlosCaPe/octorato

yeet

Use only when the user explicitly asks to stage, commit, push, and open a GitHub pull request in one flow using the GitHub CLI (`gh`).

★ 18
CarlosCaPe
CarlosCaPe/octorato

wrangler

Cloudflare Workers CLI for deploying, developing, and managing Workers, KV, R2, D1, Vectorize, Hyperdrive, Workers AI, Containers, Queues, Workflows, Pipelines, and Secrets Store. Load before running wrangler commands to ensure correct syntax and best practices. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.

★ 18
CarlosCaPe
CarlosCaPe/octorato

workspace-skill-discovery

Discover and include ALL skills across the workspace — not just global ones. Use at the start of every session or when the user asks about available skills. Ensures project-level skills (under .claude/skills/ or skills/ in any repo) are never missed.

★ 18
CarlosCaPe
CarlosCaPe/octorato

workers-best-practices

Reviews and authors Cloudflare Workers code against production best practices. Load when writing new Workers, reviewing Worker code, configuring wrangler.jsonc, or checking for common Workers anti-patterns (streaming, floating promises, global state, secrets, bindings, observability). Biases towards retrieval from Cloudflare docs over pre-trained knowledge.

★ 18
CarlosCaPe
CarlosCaPe/octorato

winui-app

Create, build and design WinUI 3 desktop apps with C# and the Windows App SDK following Microsoft's official guidance and CommunityToolkit. Covers XAML, navigation, theming, accessibility and deployment.

★ 18
CarlosCaPe
CarlosCaPe/octorato

windows-brain-script-portability

Scripts in ~/.claude/scripts/ that run on a Windows brain: use the python3.cmd shim and not bare python3, and reconfigure stdout to UTF-8 if you print symbols. Use it when writing a brain script or triaging a Windows-only crash.

★ 18