css-expert
它能做什么
这个技能为现代 CSS 提供指导,包括 flexbox、grid、自定义属性和容器查询,用于制作自适应布局。适合构建网页的前端开发者和设计师。
适用场景
- ✓当你需要一个从手机到桌面都能自适应的页面布局时。
- ✓当你要为某个区块在 flexbox 和 grid 之间做选择时。
- ✓当你希望把颜色和间距保存为设计令牌以便重复使用时。
技能链接
https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/css-expert/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请把我的产品卡片排成自适应网格,桌面端显示三列,手机端显示一列。”
每周 5 个新技能,1 分钟读完。
工作原理
该技能推荐用 flexbox 处理单行或单列,用 grid 处理二维布局,用自定义属性实现主题,并使用移动优先的媒体查询。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
CSS Expert
A front-end layout specialist with deep command of modern CSS, from flexbox and grid to container queries and cascade layers. This skill provides precise, standards-compliant guidance for building responsive, accessible, and maintainable user interfaces using the latest CSS specifications and best practices.
Key Principles
- Use flexbox for one-dimensional layouts (rows or columns) and CSS Grid for two-dimensional layouts (rows and columns simultaneously)
- Embrace custom properties (CSS variables) for theming, spacing scales, and any value that repeats or needs runtime adjustment
- Design mobile-first with min-width media queries, layering complexity as viewport size increases
- Prefer logical properties (inline-start, block-end) over physical ones (left, bottom) for internationalization-ready layouts
- Leverage the cascade intentionally with @layer declarations to control specificity without resorting to !important
Techniques
- Use flexbox justify-content and align-items for main-axis and cross-axis alignment; flex-wrap with gap for fluid card layouts
- Define CSS Grid layouts with grid-template-areas for named regions, and auto-fit/auto-fill with minmax() for responsive grids without media queries
- Create design tokens as custom properties on :root (--color-primary, --space-md) and override them in scoped selectors or media queries
- Use @container queries to style components based on their parent container size rather than the viewport
- Build animations with @keyframes and animation shorthand; prefer transform and opacity for GPU-accelerated, jank-free motion
- Apply transitions on interactive states (hover, focus-visible) with appropriate duration (150-300ms) and easing functions
- Use the :has() selector for parent-aware styling, :is()/:where() for grouping selectors with controlled specificity
Common Patterns
- Holy Grail Layout: CSS Grid with grid-template-rows (auto 1fr auto) and grid-template-columns (sidebar content sidebar) for header/footer/sidebar page structures
- Fluid Typography: clamp(1rem, 2.5vw, 2rem) for font sizes that scale smoothly between minimum and maximum values without breakpoints
- Aspect Ratio Boxes: Use the aspect-ratio property directly instead of the legacy padding-bottom hack for responsive media containers
- Dark Mode Toggle: Define color tokens as custom properties, swap them inside a prefers-color-scheme media query or a data-theme attribute selector
Pitfalls to Avoid
- Do not use fixed pixel widths for layout containers; prefer percentage, fr units, or min/max constraints for fluid responsiveness
- Do not stack z-index values arbitrarily; establish a z-index scale in custom properties and document each layer's purpose
- Do not rely on vendor prefixes without checking current browser support; tools like autoprefixer handle this systematically
- Do not nest selectors excessively in preprocessors, as the generated CSS becomes highly specific and difficult to maintain or override
常见问题
什么时候应该用 grid 而不是 flexbox?
当布局需要同时处理行和列时用 grid;只排一行项目时用 flexbox。
什么是设计令牌?
它是有名字的值,例如主色或间距大小,以 CSS 自定义属性的形式保存,并在整个页面中重复使用。
它能避免使用 !important 覆盖吗?
能。该技能建议用级联层来控制优先级,而不是依赖 !important。
详情
作者的原始描述
CSS expert for flexbox, grid, animations, responsive design, and modern layout techniques
repo: RightNow-AI/openfang
热度
- GitHub 星标
- 18k
- 排名
- #10671
- 许可证
- Apache-2.0
- 更新时间
- 2026/7/2
评论
- …
同一仓库的更多技能
browser-automation
18k教你的智能体使用 Playwright 控制网页浏览器,借助 CSS 选择器找到按钮、表单和链接。
clip-hand-skill
18k帮你的智能体制作视频片段:下载视频、转录语音、生成字幕文件,并用 ffmpeg 剪辑片段。
collector-hand-skill
18k帮你的智能体收集某个主题或公司的公开信息,提取关键实体,跟踪变化并判断舆论倾向。
infisical-sync-skill
18k帮你的智能体通过 API 读取和更新 Infisical 保险库中的密钥,包含登录步骤和清晰的错误处理。