{"id":"fa67a418-e281-43fd-8fcb-7a3685969d5e","shortId":"hjct67","kind":"skill","title":"css-debug","tagline":"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.","description":"# CSS Debug Skill\n\n<command-name>css-debug</command-name>\n<user-invocable>true</user-invocable>\n\n## 使用场景\n\n当用户遇到以下问题时使用此 skill：\n- CSS 定位问题（元素位置不正确、被裁剪、溢出等）\n- React 组件渲染问题\n- Tailwind CSS 类不生效\n- 绝对定位/相对定位问题\n- Flexbox/Grid 布局问题\n- z-index 层叠问题\n\n## 调试步骤\n\n### 1. 收集信息\n\n首先向用户询问或获取：\n- 浏览器开发者工具中的 HTML 结构\n- 相关元素的 computed styles\n- 父容器的 CSS 属性（特别是 position、overflow、display）\n- 截图（如果有的话）\n\n### 2. 常见问题检查清单\n\n#### 绝对定位内容被裁剪\n```\n问题：position: absolute 的元素被父容器裁剪\n检查：\n- [ ] 父容器是否有 overflow: hidden 或 overflow: auto\n- [ ] 祖先容器是否有 overflow: hidden\n- [ ] 父容器是否设置了 position: relative\n- [ ] 元素的 top/left/right/bottom 值是否超出父容器\n\n解决方案：\n1. 将 overflow: hidden 改为 overflow: visible\n2. 或将绝对定位元素移到更外层的容器\n3. 或使用 fixed 定位（相对于视口）\n```\n\n#### 元素位置偏移\n```\n问题：元素位置与预期不符\n检查：\n- [ ] positionX/positionY 或 left/top 值是否正确\n- [ ] 最近的 position: relative 祖先是哪个\n- [ ] 是否有 margin/padding 影响\n- [ ] transform 是否影响定位上下文\n\n解决方案：\n1. 确认定位参考点是正确的祖先元素\n2. 检查 CSS 单位（px vs % vs rem）\n3. 使用浏览器检查器的\"元素选择\"功能定位问题\n```\n\n#### 内容不显示\n```\n问题：React 组件渲染但内容不可见\n检查：\n- [ ] 元素是否有 width/height（可能为 0）\n- [ ] opacity 是否为 0\n- [ ] visibility 是否为 hidden\n- [ ] display 是否为 none\n- [ ] z-index 是否被其他元素遮挡\n- [ ] color 是否与背景色相同\n\n解决方案：\n1. 在开发者工具中检查 Computed 面板\n2. 临时添加边框或背景色调试：border: 1px solid red\n3. 检查条件渲染逻辑\n```\n\n#### Tailwind 类不生效\n```\n问题：Tailwind CSS 类没有应用\n检查：\n- [ ] 类名拼写是否正确\n- [ ] 是否被更高优先级的样式覆盖\n- [ ] 动态类名是否正确生成（字符串拼接问题）\n- [ ] tailwind.config.js 中 content 配置是否包含该文件\n\n解决方案：\n1. 使用 !important 临时测试：!overflow-visible\n2. 检查 className 是否正确传递\n3. 使用内联 style 作为备选方案\n```\n\n### 3. 浏览器调试命令\n\n在浏览器控制台运行：\n\n```javascript\n// 高亮所有绝对定位元素\ndocument.querySelectorAll('[style*=\"position: absolute\"]').forEach(el => {\n  el.style.outline = '2px solid red';\n  console.log(el, getComputedStyle(el));\n});\n\n// 查找 overflow: hidden 的容器\ndocument.querySelectorAll('*').forEach(el => {\n  const style = getComputedStyle(el);\n  if (style.overflow === 'hidden' || style.overflowX === 'hidden' || style.overflowY === 'hidden') {\n    el.style.outline = '2px dashed blue';\n    console.log('overflow-hidden:', el);\n  }\n});\n\n// 检查元素的完整 computed 样式\nconst el = document.querySelector('.your-selector');\nconsole.table({\n  position: getComputedStyle(el).position,\n  overflow: getComputedStyle(el).overflow,\n  display: getComputedStyle(el).display,\n  width: getComputedStyle(el).width,\n  height: getComputedStyle(el).height,\n  top: getComputedStyle(el).top,\n  left: getComputedStyle(el).left,\n});\n\n// 查找定位祖先\nfunction findPositionedAncestor(el) {\n  let current = el.parentElement;\n  while (current) {\n    const position = getComputedStyle(current).position;\n    if (position !== 'static') {\n      console.log('Positioned ancestor:', current, 'position:', position);\n      return current;\n    }\n    current = current.parentElement;\n  }\n  console.log('No positioned ancestor found, using viewport');\n  return null;\n}\nfindPositionedAncestor(document.querySelector('.your-selector'));\n```\n\n### 4. React DevTools 检查\n\n1. 打开 React DevTools\n2. 选择问题组件\n3. 检查：\n   - props 是否正确传递\n   - state 是否包含预期数据\n   - 条件渲染的条件是否满足\n\n### 5. 常用修复模式\n\n#### 修复绝对定位被裁剪\n\n```tsx\n// 问题代码\n<div className=\"relative overflow-hidden\">\n  <div style={{ position: 'absolute', top: 200, left: 100 }}>\n    被裁剪的内容\n  </div>\n</div>\n\n// 解决方案 1: 移除 overflow-hidden\n<div className=\"relative overflow-visible\">\n  ...\n</div>\n\n// 解决方案 2: 条件性 overflow\nconst hasAbsoluteContent = blocks.some(b => b.props?.positionX !== undefined);\n<div className={`relative ${hasAbsoluteContent ? '' : 'overflow-hidden'}`}>\n  ...\n</div>\n\n// 解决方案 3: 分离容器\n<div className=\"relative\">\n  <div className=\"overflow-hidden\">\n    {/* 需要裁剪的内容 */}\n  </div>\n  <div className=\"absolute-content-wrapper\">\n    {/* 绝对定位内容 */}\n  </div>\n</div>\n```\n\n## 输出格式\n\n分析完成后，提供：\n\n1. **问题诊断**：明确说明是什么导致了问题\n2. **原因分析**：解释 CSS 机制和为什么会发生这种情况\n3. **解决方案**：提供具体的代码修改建议\n4. **验证步骤**：告诉用户如何验证修复是否有效\n\n## 示例对话\n\n用户：我的绝对定位元素被裁剪了\n\nClaude：\n1. 请在浏览器中运行以下命令查找 overflow:hidden 的容器：\n   ```javascript\n   document.querySelectorAll('*').forEach(el => {\n     const style = getComputedStyle(el);\n     if (style.overflow === 'hidden') {\n       el.style.outline = '2px dashed blue';\n       console.log('overflow-hidden:', el);\n     }\n   });\n   ```\n2. 请告诉我哪些容器被标记出来了\n3. 同时，请检查绝对定位元素的父容器是否有 `position: relative`","tags":["css","debug","claude","arsenal","majiayu000","agent-skills","ai-agents","ai-coding-assistant","automation","claude-code","code-review","developer-tools"],"capabilities":["skill","source-majiayu000","skill-css-debug","topic-agent-skills","topic-ai-agents","topic-ai-coding-assistant","topic-automation","topic-claude","topic-claude-code","topic-code-review","topic-developer-tools","topic-devops","topic-productivity","topic-prompt-engineering","topic-python"],"categories":["claude-arsenal"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/majiayu000/claude-arsenal/css-debug","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add majiayu000/claude-arsenal","source_repo":"https://github.com/majiayu000/claude-arsenal","install_from":"skills.sh"}},"qualityScore":"0.464","qualityRationale":"deterministic score 0.46 from registry signals: · indexed on github topic:agent-skills · 29 github stars · SKILL.md body (4,145 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-01T07:01:13.330Z","embedding":null,"createdAt":"2026-04-18T22:24:06.344Z","updatedAt":"2026-05-01T07:01:13.330Z","lastSeenAt":"2026-05-01T07:01:13.330Z","tsv":"'0':156,159 '1':60,102,134,173,201,345,373,404,422 '100':370 '1px':180 '2':78,109,136,177,208,349,379,407,447 '200':368 '2px':228,254,439 '3':111,144,183,212,216,351,397,412,449 '4':341,415 '5':358 'absolut':83,224,366 'ancestor':319,330 'auto':91 'b':385 'b.props':386 'blocks.some':384 'blue':256,441 'border':179 'class':20 'classnam':210,390 'claud':421 'clip':18 'color':170 'comput':67,175,263 'conflict':21 'console.log':231,257,317,327,442 'console.table':271 'const':242,265,309,382,431 'content':198 'css':2,9,31,35,41,49,70,138,189,410 'css-debug':1,34 'current':305,308,312,320,324,325 'current.parentelement':326 'dash':255,440 'debug':3,32,36 'devtool':343,348 'diagnos':8 'display':75,163,280,283 'div':363,389 'document.queryselector':267,337 'document.queryselectorall':221,239,428 'el':226,232,234,241,245,261,266,274,278,282,286,290,294,298,303,430,434,446 'el.parentelement':306 'el.style.outline':227,253,438 'findpositionedancestor':302,336 'fix':113 'flexbox/grid':53 'foreach':225,240,429 'found':331 'frontend':11 'function':301 'getcomputedstyl':233,244,273,277,281,285,289,293,297,311,433 'hasabsolutecont':383,392 'height':288,291 'hidden':88,94,105,162,237,248,250,252,260,377,395,425,437,445 'html':64 'import':203 'index':24,57,168 'issu':13 'javascript':219,427 'layout':12 'left':296,299,369 'left/top':122 'let':304 'margin/padding':129 'none':165 'null':335 'opac':157 'overflow':17,74,87,90,93,104,107,206,236,259,276,279,376,381,394,424,444 'overflow-hidden':258,375,393,443 'overflow-vis':205 'posit':16,73,82,96,125,223,272,275,310,313,315,318,321,322,329,365,452 'positionx':387 'positionx/positiony':120 'problem':30 'prop':353 'px':140 'react':27,46,150,342,347 'red':182,230 'relat':97,126,391,453 'rem':143 'render':28 'return':323,334 'selector':270,340 'skill':6,33,40 'skill-css-debug' 'solid':181,229 'source-majiayu000' 'stack':25 'state':355 'static':316 'style':68,214,222,243,364,432 'style.overflow':247,436 'style.overflowx':249 'style.overflowy':251 'tailwind':19,48,185,188 'tailwind.config.js':196 'top':292,295,367 'top/left/right/bottom':99 'topic-agent-skills' 'topic-ai-agents' 'topic-ai-coding-assistant' 'topic-automation' 'topic-claude' 'topic-claude-code' 'topic-code-review' 'topic-developer-tools' 'topic-devops' 'topic-productivity' 'topic-prompt-engineering' 'topic-python' 'transform':131 'true':37 'tsx':361 'undefin':388 'use':4,332 'viewport':333 'visibl':29,108,160,207 'vs':141,142 'width':284,287 'width/height':154 'your-selector':268,338 'z':23,56,167 'z-index':22,55,166 '中':197 '临时测试':204 '临时添加边框或背景色调试':178 '作为备选方案':215 '使用':202 '使用内联':213 '使用场景':38 '使用浏览器检查器的':145 '修复绝对定位被裁剪':360 '值是否正确':123 '值是否超出父容器':100 '元素位置不正确':43 '元素位置与预期不符':118 '元素位置偏移':116 '元素是否有':153 '元素的':98 '元素选择':146 '内容不显示':148 '分析完成后':402 '分离容器':398 '功能定位问题':147 '动态类名是否正确生成':194 '单位':139 '原因分析':408 '可能为':155 '同时':450 '告诉用户如何验证修复是否有效':417 '在开发者工具中检查':174 '在浏览器控制台运行':218 '如果有的话':77 '字符串拼接问题':195 '定位':114 '定位问题':42 '将':103 '层叠问题':58 '属性':71 '布局问题':54 '常用修复模式':359 '常见问题检查清单':79 '当用户遇到以下问题时使用此':39 '影响':130 '我的绝对定位元素被裁剪了':420 '或':89,121 '或使用':112 '或将绝对定位元素移到更外层的容器':110 '截图':76 '打开':346 '提供':403 '提供具体的代码修改建议':414 '收集信息':61 '改为':106 '明确说明是什么导致了问题':406 '是否与背景色相同':171 '是否为':158,161,164 '是否包含预期数据':356 '是否影响定位上下文':132 '是否有':128 '是否正确传递':211,354 '是否被其他元素遮挡':169 '是否被更高优先级的样式覆盖':193 '最近的':124 '机制和为什么会发生这种情况':411 '条件性':380 '条件渲染的条件是否满足':357 '查找':235 '查找定位祖先':300 '样式':264 '检查':85,119,137,152,191,209,344,352 '检查元素的完整':262 '检查条件渲染逻辑':184 '浏览器开发者工具中的':63 '浏览器调试命令':217 '溢出等':45 '父容器是否有':86 '父容器是否设置了':95 '父容器的':69 '特别是':72 '用户':419 '的元素被父容器裁剪':84 '的容器':238,426 '相关元素的':66 '相对于视口':115 '相对定位问题':52 '确认定位参考点是正确的祖先元素':135 '示例对话':418 '祖先容器是否有':92 '祖先是哪个':127 '移除':374 '类不生效':50,186 '类名拼写是否正确':192 '类没有应用':190 '组件渲染但内容不可见':151 '组件渲染问题':47 '结构':65 '绝对定位':51 '绝对定位内容':400 '绝对定位内容被裁剪':80 '被裁剪':44 '被裁剪的内容':371 '解决方案':101,133,172,200,372,378,396,413 '解释':409 '请告诉我哪些容器被标记出来了':448 '请在浏览器中运行以下命令查找':423 '请检查绝对定位元素的父容器是否有':451 '调试步骤':59 '输出格式':401 '选择问题组件':350 '配置是否包含该文件':199 '问题':81,117,149,187 '问题代码':362 '问题诊断':405 '需要裁剪的内容':399 '面板':176 '首先向用户询问或获取':62 '验证步骤':416 '高亮所有绝对定位元素':220","prices":[{"id":"996dd3bc-e673-4569-9f7a-618679a2859c","listingId":"fa67a418-e281-43fd-8fcb-7a3685969d5e","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"majiayu000","category":"claude-arsenal","install_from":"skills.sh"},"createdAt":"2026-04-18T22:24:06.344Z"}],"sources":[{"listingId":"fa67a418-e281-43fd-8fcb-7a3685969d5e","source":"github","sourceId":"majiayu000/claude-arsenal/css-debug","sourceUrl":"https://github.com/majiayu000/claude-arsenal/tree/main/skills/css-debug","isPrimary":false,"firstSeenAt":"2026-04-18T22:24:06.344Z","lastSeenAt":"2026-05-01T07:01:13.330Z"}],"details":{"listingId":"fa67a418-e281-43fd-8fcb-7a3685969d5e","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"majiayu000","slug":"css-debug","github":{"repo":"majiayu000/claude-arsenal","stars":29,"topics":["agent-skills","ai-agents","ai-coding-assistant","automation","claude","claude-code","code-review","developer-tools","devops","productivity","prompt-engineering","python","software-development","typescript","workflows"],"license":"mit","html_url":"https://github.com/majiayu000/claude-arsenal","pushed_at":"2026-04-29T04:12:22Z","description":"52 production-ready Claude Code skills and 7 specialized agents for software development, DevOps, product workflows, and automation.","skill_md_sha":"4b0714ce11768c3cbc6997869fe0fd8818322f4d","skill_md_path":"skills/css-debug/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/majiayu000/claude-arsenal/tree/main/skills/css-debug"},"layout":"multi","source":"github","category":"claude-arsenal","frontmatter":{"name":"css-debug","description":"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."},"skills_sh_url":"https://skills.sh/majiayu000/claude-arsenal/css-debug"},"updatedAt":"2026-05-01T07:01:13.330Z"}}