horizontal-scroll
它能做什么
这项技能检查页面在手机上以及浏览器高缩放比例下是否适应宽度。适用于希望布局对每个人都有效的开发者和设计师。
适用场景
- ✓当手机上的访客需要左右滚动才能阅读页面的时候。
- ✓当宽表格或图片把页面推出屏幕范围的时候。
- ✓当你需要满足高缩放下的重排无障碍规则的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/horizontal-scroll/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请检查我的页面在手机上或放大时是否会左右滚动。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会查找固定宽度、过长且无法断行的文字,以及超出容器的媒体。它会建议使用流式宽度、将媒体的 max-width 设为 100%,并对长文字使用自动换行。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Prevent horizontal scrolling
Low-vision users who cannot read at standard zoom levels increase browser zoom to 200–400%. At these zoom levels, a 1280px-wide page becomes effectively 320px wide. If elements overflow the viewport, users must scroll both vertically and horizontally to read content — this is exhausting and error-prone with a screen magnifier. WCAG 2.1 SC 1.4.10 (Reflow) specifically addresses this, requiring that all content is available without two-dimensional scrolling at 400% zoom.
Quick Reference
- Pages must not produce horizontal scrollbars at viewport widths of 320px and above — WCAG 2.1 SC 1.4.10 (Reflow)
- WCAG 2.1 SC 1.4.10 requires content to reflow at 400% zoom (equivalent to 320px CSS width) without horizontal scroll
- Common causes: fixed-width elements wider than the viewport,
width: 100vwnot accounting for scrollbar width, long unbreakable strings,white-space: nowrap - Use
max-width: 100%on images and media,overflow-wrap: break-wordon text containers, and fluid layout units
Check
Test the page at a 320px CSS viewport width (equivalent to 400% browser zoom on a 1280px screen). Look for horizontal scrollbars or content overflowing outside the viewport. Specifically check: (1) elements with fixed width values in px that exceed the viewport; (2) min-width values that prevent shrinking; (3) images or media without max-width: 100%; (4) white-space: nowrap on text that causes overflow; (5) width: 100vw on elements (scrollbar width causes overflow); (6) long URLs or unbreakable strings in content areas.
Fix
(1) Replace fixed width: Npx on layout containers with max-width: Npx plus width: 100%. (2) Add max-width: 100% and height: auto to all images and media. (3) Apply overflow-wrap: break-word (with fallback word-wrap: break-word) to text containers that may contain long strings. (4) Replace width: 100vw with width: 100% on full-width elements (avoid scrollbar overflow). (5) Use CSS Grid or Flexbox with flex-wrap: wrap for multi-column layouts. (6) For data tables, wrap in a scrollable container: overflow-x: auto on the table wrapper, not the page body.
Explain
WCAG 2.1 SC 1.4.10 (Reflow, Level AA) requires that content does not require two-dimensional scrolling when displayed at a width of 320 CSS pixels or a height of 256 CSS pixels. This corresponds to 400% zoom on a 1280×1024 display. Exceptions are made for content that requires two-dimensional layout for usage (e.g., data tables, map interfaces, video). For all other content — body text, navigation, forms, images — horizontal scrolling is a barrier for screen magnification users who cannot see the full page width.
Code Review
Review stylesheets, component styles, and responsive states related to Prevent horizontal scrolling. Flag exact selectors, declarations, or breakpoints that violate the rule in the rendered UI.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/css/horizontal-scroll
常见问题
测试的是什么宽度?
这项技能建议以 320 像素宽度进行测试,这与典型桌面屏幕上 400% 缩放的效果相当。
大多数左右滚动是由什么引起的?
这项技能列出的原因包括固定宽度元素、过长的不可断行字符串、nowrap 设置,以及忽略滚动条的 100vw 宽度。
适用哪条无障碍规则?
它引用 WCAG 2.1 成功标准 1.4.10,要求内容可以在不需要双向滚动的情况下重排。
详情
作者的原始描述
Use when applies to all CSS layout rules. Check `width`, `min-width`, fixed pixel values on containers, `overflow`, `white-space`, and `word-break` properties. Use when auditing responsive design or WCAG 2.1 Level AA compliance. Test at 320px viewport width and at 400% browser zoom.
热度
- GitHub 星标
- 75k
- 排名
- #2868
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。