Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use this skill to diagnose CSS and frontend layout issues such as positioning, overflow clipping, Tailwind class conflicts, z-index stacking, and React rendering visibility problems.
.claude/skills/majiayu000-css-debug/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✓→✓ | = Same ✓ | 62% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 48% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 45% | 0% |
| case-06 | ✓→✓ | = Same ✓ | 47% | 0% |
| case-07 | ✓→✓ | = Same ✓ | 152% | 0% |
<command-name>css-debug</command-name> <user-invocable>true</user-invocable>
当用户遇到以下问题时使用此 skill:
首先向用户询问或获取:
问题:position: absolute 的元素被父容器裁剪
检查:
- [ ] 父容器是否有 overflow: hidden 或 overflow: auto
- [ ] 祖先容器是否有 overflow: hidden
- [ ] 父容器是否设置了 position: relative
- [ ] 元素的 top/left/right/bottom 值是否超出父容器
解决方案:
1. 将 overflow: hidden 改为 overflow: visible
2. 或将绝对定位元素移到更外层的容器
3. 或使用 fixed 定位(相对于视口)问题:元素位置与预期不符
检查:
- [ ] positionX/positionY 或 left/top 值是否正确
- [ ] 最近的 position: relative 祖先是哪个
- [ ] 是否有 margin/padding 影响
- [ ] transform 是否影响定位上下文
解决方案:
1. 确认定位参考点是正确的祖先元素
2. 检查 CSS 单位(px vs % vs rem)
3. 使用浏览器检查器的"元素选择"功能定位问题问题:React 组件渲染但内容不可见
检查:
- [ ] 元素是否有 width/height(可能为 0)
- [ ] opacity 是否为 0
- [ ] visibility 是否为 hidden
- [ ] display 是否为 none
- [ ] z-index 是否被其他元素遮挡
- [ ] color 是否与背景色相同
解决方案:
1. 在开发者工具中检查 Computed 面板
2. 临时添加边框或背景色调试:border: 1px solid red
3. 检查条件渲染逻辑问题:Tailwind CSS 类没有应用
检查:
- [ ] 类名拼写是否正确
- [ ] 是否被更高优先级的样式覆盖
- [ ] 动态类名是否正确生成(字符串拼接问题)
- [ ] tailwind.config.js 中 content 配置是否包含该文件
解决方案:
1. 使用 !important 临时测试:!overflow-visible
2. 检查 className 是否正确传递
3. 使用内联 style 作为备选方案在浏览器控制台运行:
javascript// 高亮所有绝对定位元素 document.querySelectorAll('[style*="position: absolute"]').forEach(el => { el.style.outline = '2px solid red'; console.log(el, getComputedStyle(el)); }); // 查找 overflow: hidden 的容器 document.querySelectorAll('*').forEach(el => { const style = getComputedStyle(el); if (style.overflow === 'hidden' || style.overflowX === 'hidden' || style.overflowY === 'hidden') { el.style.outline = '2px dashed blue'; console.log('overflow-hidden:', el); } }); // 检查元素的完整 computed 样式 const el = document.querySelector('.your-selector'); console.table({ position: getComputedStyle(el).position, overflow: getComputedStyle(el).overflow, display: getComputedStyle(el).display, width: getComputedStyle(el).width, height: getComputedStyle(el).height, top: getComputedStyle(el).top, left: getComputedStyle(el).left, }); // 查找定位祖先 function findPositionedAncestor(el) { let current = el.parentElement; while (current) { const position = getComputedStyle(current).position; if (position !== 'static') { console.log('Positioned ancestor:', current, 'position:', position); return current; } current = current.parentElement; } console.log('No positioned ancestor found, using viewport'); return null; } findPositionedAncestor(document.querySelector('.your-selector'));
tsx// 问题代码 <div className="relative overflow-hidden"> <div style={{ position: 'absolute', top: 200, left: 100 }}> 被裁剪的内容 </div> </div> // 解决方案 1: 移除 overflow-hidden <div className="relative overflow-visible"> ... </div> // 解决方案 2: 条件性 overflow const hasAbsoluteContent = blocks.some(b => b.props?.positionX !== undefined); <div className={`relative ${hasAbsoluteContent ? '' : 'overflow-hidden'}`}> ... </div> // 解决方案 3: 分离容器 <div className="relative"> <div className="overflow-hidden"> {/* 需要裁剪的内容 */} </div> <div className="absolute-content-wrapper"> {/* 绝对定位内容 */} </div> </div>
分析完成后,提供:
用户:我的绝对定位元素被裁剪了
Claude:
javascript document.querySelectorAll('*').forEach(el => { const style = getComputedStyle(el); if (style.overflow === 'hidden') { el.style.outline = '2px dashed blue'; console.log('overflow-hidden:', el); } });
position: relative| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 14,432 | 12,536 | -13% | 1 | 1 | 0% | 2,522 | 3,651 | +45% | 0 | 0 | — |
case-02 | fail→fail | 16,010 | 14,604 | -9% | 1 | 1 | 0% | 2,930 | 4,122 | +41% | 0 | 0 | — |
case-03 | pass→pass | 12,334 | 11,727 | -5% | 1 | 1 | 0% | 2,151 | 3,488 | +62% | 0 | 0 | — |
case-04 | pass→pass | 11,402 | 7,225 | -37% | 1 | 1 | 0% | 1,932 | 2,860 | +48% | 0 | 0 | — |
case-05 | pass→pass | 15,861 | 16,338 | +3% | 1 | 1 | 0% | 3,377 | 4,892 | +45% | 0 | 0 | — |
case-06 | pass→pass | 14,302 | 11,891 | -17% | 1 | 1 | 0% | 2,461 | 3,610 | +47% | 0 | 0 | — |
case-07 | pass→pass | 6,365 | 5,694 | -11% | 1 | 1 | 0% | 961 | 2,418 | +152% | 0 | 0 | — |
case-08 | pass→pass | 3,522 | 5,125 | +46% | 1 | 1 | 0% | 603 | 2,413 | +300% | 0 | 0 | — |
case-09 | pass→pass | 9,875 | 7,755 | -21% | 1 | 1 | 0% | 1,657 | 2,997 | +81% | 0 | 0 | — |
case-10 | pass→pass | 12,110 | 10,499 | -13% | 1 | 1 | 0% | 2,062 | 3,153 | +53% | 0 | 0 | — |
case-11 | pass→pass | 11,428 | 11,897 | +4% | 1 | 1 | 0% | 1,953 | 3,525 | +80% | 0 | 0 | — |
case-12 | pass→pass | 13,497 | 13,104 | -3% | 1 | 1 | 0% | 2,559 | 3,874 | +51% | 0 | 0 | — |
case-13 | pass→pass | 9,415 | 12,673 | +35% | 1 | 1 | 0% | 1,640 | 3,117 | +90% | 0 | 0 | — |
case-14 | pass→pass | 14,302 | 8,374 | -41% | 1 | 1 | 0% | 2,979 | 3,028 | +2% | 0 | 0 | — |
case-15 | pass→pass | 8,876 | 5,630 | -37% | 1 | 1 | 0% | 1,517 | 2,554 | +68% | 0 | 0 | — |
case-16 | pass→pass | 11,474 | 13,003 | +13% | 1 | 1 | 0% | 1,735 | 3,794 | +119% | 0 | 0 | — |
case-17 | pass→pass | 5,064 | 5,491 | +8% | 1 | 1 | 0% | 841 | 2,415 | +187% | 0 | 0 | — |
case-18 | pass→pass | 14,332 | 11,231 | -22% | 1 | 1 | 0% | 2,230 | 3,412 | +53% | 0 | 0 | — |
case-19 | pass→pass | 12,571 | 16,402 | +30% | 1 | 1 | 0% | 2,014 | 4,346 | +116% | 0 | 0 | — |
case-20 | pass→pass | 12,448 | 8,514 | -32% | 1 | 1 | 0% | 2,212 | 2,984 | +35% | 0 | 0 | — |
case-21 | pass→pass | 12,218 | 12,688 | +4% | 1 | 1 | 0% | 2,283 | 3,954 | +73% | 0 | 0 | — |
case-22 | pass→pass | 15,784 | 13,371 | -15% | 1 | 1 | 0% | 2,950 | 3,942 | +34% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of 0 percentage points is the difference between those two pass rates over the 22 comparable cases.
Other measured skills in the registry, with their headline benchmark lift.