css-debug

A troubleshooting guide for CSS and frontend layout problems in web applications, including React and Tailwind CSS.

In plain words
What is it for?
Checking positioning, overflow, Flexbox and Grid layouts, z-index stacking, computed styles, Tailwind classes, and React rendering or visibility issues.
Why use it?
It helps explain why elements are misplaced, clipped, hidden, covered by other elements, or unaffected by expected styles.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/majiayu000/spellbook/css-debug
Any agent
npx skills add majiayu000/spellbook --skill css-debug
Clone the repo
git clone --depth 1 https://github.com/majiayu000/spellbook

Made for: Claude Code, Codex.

Per session 35 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,606 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00035 $0.01606
Opus 5 $0.00017 $0.00803
Sonnet 5 $0.00007 $0.00321
Haiku 4.5 $0.00003 $0.00161

Measured 3d ago against content hash 38bfe7d7ab0b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

css-debug scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/css-debug/SKILL.md · 216 lines

How it starts

The opening of the file, as written. The whole thing — 216 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CSS Debug Skill

css-debug true

使用场景

当用户遇到以下问题时使用此 skill:

  • CSS 定位问题(元素位置不正确、被裁剪、溢出等)
  • React 组件渲染问题
  • Tailwind CSS 类不生效
  • 绝对定位/相对定位问题
  • Flexbox/Grid 布局问题
  • z-index 层叠问题

调试步骤

1. 收集信息

首先向用户询问或获取:

  • 浏览器开发者工具中的 HTML 结构
  • 相关元素的 computed styles
  • 父容器的 CSS 属性(特别是 position、overflow、display)
  • 截图(如果有的话)

2. 常见问题检查清单

绝对定位内容被裁剪
问题: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 类不生效
问题:Tailwind CSS 类没有应用
检查:
- [ ] 类名拼写是否正确
- [ ] 是否被更高优先级的样式覆盖
- [ ] 动态类名是否正确生成(字符串拼接问题)
- [ ] tailwind.config.js 中 content 配置是否包含该文件

解决方案:
1. 使用 !important 临时测试:!overflow-visible
2. 检查 className 是否正确传递
3. 使用内联 style 作为备选方案

3. 浏览器调试命令

在浏览器控制台运行:

// 高亮所有绝对定位元素
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'));

Read the full file on GitHub · 216 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 216 lines · 35 tokens per session scan A 38bfe7d7ab0b

Subscribe to this mod's changes

css-debug is a skill published in the GitHub repository majiayu000/spellbook (263 stars, last pushed 3d ago), licensed MIT. It adds 35 tokens to every session and 1,606 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

bzdesignprompt

为前端或网页设计任务选择并下载合适的 DESIGN.md 模板。当用户需要网页设计模板、UI 风格参考、设计系统、落地页或前端界面设计时,浏览长亭百智云 UI 设计模板库,根据产品场景和视觉偏好匹配模板,并将完整 DESIGN.md 保存到项目中。.

chaitin/MonkeyCode · 79 tokens

frontend-ui-audit

Frontend UI consistency audit for React + Tailwind codebases. Use when reviewing component refactors, UI cleanup batches, or answering "should this use the design system?" — checks design-system adoption, arbitrary Tailwind values vs tokens, hardcoded sizes and colors, accessibility basics, and repeated visual…

org2AI/ORG2 · 75 tokens

tailwind-css

Tailwind CSS v4 patterns: CSS-first config, utility classes, component variants, v3 migration. Use when styling with Tailwind, configuring @theme tokens, using tailwind-variants/CVA, migrating v3 to v4, or fixing Tailwind styles and dark mode.

iliaal/ai-skills · 61 tokens

vc-frontend-design

Create polished frontend interfaces from designs/screenshots/videos. Use for web components, 3D experiences, replicating UI designs, quick prototypes, immersive interfaces, avoiding AI slop.

withkynam/vibecode-pro-max-kit · 41 tokens

app-ui-design

Guidance for visual design, UI and UX in Fusebase-generated apps. Use when building or refining app UIs: pages, components, layouts, forms, feedback states, theming, or accessibility. Ensures consistent, clear, and distinctive interfaces using shadcn/ui.

fusebase-dev/fusebase-flow · 60 tokens

frontend-design

Design and implement a distinctive, intentional product interface or website with a coherent visual system, responsive behavior, accessibility, and visual verification. Use for new frontend experiences or substantial visual reshaping; do not use for backend-only changes, static artwork, slide decks, or applying a…

evoelsewhere/evoflux · 62 tokens