focus-not-obscured
它能做什么
这项技能检查固定的页面元素是否遮住了获得键盘焦点的项目。适用于构建吸顶菜单、Cookie 横幅和聊天小组件的开发者。
适用场景
- ✓当你用 Tab 键浏览页面时,吸顶标题遮住了链接的时候。
- ✓当 Cookie 横幅遮住了键盘用户正在填写的表单字段的时候。
- ✓当你添加了固定在屏幕上的聊天启动按钮或促销栏的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/focus-not-obscured/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请检查我的吸顶标题在我使用 Tab 键时,是否会遮住获得焦点的链接。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会在吸顶元素显示的情况下测试键盘焦点,查找获得焦点的项目滚动到它们下方的情况。它会建议使用 scroll-padding,或调整覆盖层的尺寸。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Keep focused elements unobscured
A visible focus ring is not enough if the focused element sits behind a sticky header or footer. Keyboard users need to see the actual focused control and the focus indicator at the same time in order to continue the task.
Quick Reference
- Sticky UI must not cover the focused control while keyboard users tab through the page
- Use
scroll-paddingor equivalent spacing when fixed headers or footers are present - Test with cookie banners, chat widgets, and consent bars open
- Re-test at zoomed and mobile layouts where overlap problems usually appear
Check
Audit keyboard focus with all sticky UI active. Check headers, footers, cookie banners, promo bars, and chat launchers for cases where the focused element scrolls underneath them.
Fix
Add layout spacing such as scroll-padding, reduce overlay height, or change focus/scroll behavior so the focused element remains visible when tabbing.
Explain
Explain WCAG Focus Not Obscured, why fixed-position UI commonly breaks it, and how scroll-padding and overlay layout choices prevent the issue.
Code Review
Review sticky layout, focus styles, overlays, and keyboard navigation related to Keep focused elements unobscured. Flag exact selectors, breakpoints, or UI states where focused controls can be covered.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/accessibility/focus-not-obscured
常见问题
什么是 scroll-padding?
它是一项 CSS 设置,当浏览器滚动到获得焦点的项目时,会在顶部或底部留出空间,使其保持可见。
它检查哪些元素?
页眉、页脚、Cookie 横幅、促销栏和聊天启动按钮。
这些问题通常在什么时候出现?
这项技能指出,重叠问题常出现在缩放和移动端布局中,因此建议在这些情况下重新测试。
详情
作者的原始描述
Use when reviewing sticky navigation, consent banners, chat widgets, skip links, or any fixed-position UI. Validate the actual tab order and viewport behavior at realistic zoom levels.
热度
- GitHub 星标
- 75k
- 排名
- #2850
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。