专家
- 作者仓库星标 17,717
- 作者仓库 openfang
- 领域
- 设计与多媒体
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @RightNow-AI · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 即装即用
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
# 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
章节与文件索引
按说明文件中的顺序排列。
关键原则
技巧
常见模式
要避免的陷阱
文件/命令 -> auto-fit/auto-fill · header/footer/sidebar · min/max
内容校验值 -> a0f981b488a6
当前原文的自动摘译,尚未人工审校。
关键原则
使用 Flexbox 进行一维布局(行或列),使用 CSS Grid 进行二维布局(同时行和列) 使用自定义属性(CSS 变量)进行主题、间距比例以及任何重复或需要运行时调整的值 使用最小宽度媒体查询设计移动优先,随着视口大小的增加分层复杂性 对于国际化就绪的布局,优先选择逻辑属性(内联开始、块结束)而不是物理属性(左、下)
技巧
使用flexbox justify-content和align-items进行主轴和横轴对齐;带有间隙的 flex-wrap 用于流体卡布局使用 grid-template-areas 为命名区域定义 CSS 网格布局,并使用 minmax() 自动调整/自动填充以实现无媒体查询的响应式网格在 :root (--color-primary、--space-md) 上创建设计令牌作为自定义属性,并在作用域选择器或媒体查询中覆盖它们
常见模式
圣杯布局:带有 grid-template-rows (auto 1fr auto) 和 grid-template-columns (sidebar content sidebar) 的 CSS 网格,用于页眉/页脚/侧边栏页面结构流体排版:clamp(1rem, 2.5vw, 2rem) 用于字体大小在最小和最大值之间平滑缩放,没有断点长宽比框:直接使用宽高比属性,而不是响应媒体容器的传统 padding-bottom hack
要避免的陷阱
不要对布局容器使用固定像素宽度;优选百分比、fr 单位或流体响应的最小/最大约束 不要任意堆叠 z 索引值;在自定义属性中建立 z-index 比例并记录每个层的用途 不要在未检查当前浏览器支持的情况下依赖供应商前缀;像 autoprefixer 这样的工具系统地处理这个问题 不要在预处理器中过度嵌套选择器,因为生成的 CSS 变得高度特定并且难以维护或覆盖