Components: Grid Layout
Guides grid layout design for equal-hierarchy, multi-column content display. Grids display multiple items with equal emphasis; space-efficient and scannable. Used for products, templates, tools, features, blog indexes, and galleries.
When invoking: On first use, if helpful, open with 1–2 sentences on what this skill covers and why it matters, then provide the main output. On subsequent use or when the user asks to skip, go directly to the main output.
When to Use Grid
| Use grid when | Use list when |
|---|
| Visual content (images, thumbnails) | Text-heavy; scan by title |
| Equal emphasis across items |
Compact; many items; dense info |
| Products, templates, gallery, features | Blog index, docs, search results |
| Browsing, discovery | Reading, scanning |
See list for list layout; card for card structure within grid.
Grid Structure
| Element | Purpose |
|---|
| Columns | 1–4+ columns; adapt to viewport |
| Gap |
Consistent spacing between items |
|
Items | Equal or proportional sizing |
|
Responsive | 1 col mobile → 2–4 cols desktop |
Implementation
- - CSS Grid:
repeat(auto-fill, minmax(min, 1fr)) or repeat(auto-fit, minmax()) for fluid columns - Breakpoints: e.g., 1 col <768px; 2 cols 768–1024px; 3–4 cols >1024px
- Consistency: Same padding, aspect ratios across items; see card for card structure
Best Practices
| Principle | Practice |
|---|
| Equal hierarchy | Items compete equally; no single dominant item |
| Consistent sizing |
Same card/item dimensions in grid |
|
Gap consistency | Uniform gap (e.g., 16px, 24px) |
|
No layout shift | Reserve space for images; avoid CLS |
Responsive
- - Mobile: Single column; full-width items
- Tablet: 2 columns; touch targets ≥44×44px
- Desktop: 3–4 columns; hover states OK
Infinite Scroll
If using infinite scroll with grid: crawlers cannot access content loaded on scroll. Provide paginated component pages for SEO-critical content. See site-crawlability for search-friendly implementation.
Related Skills
- - site-crawlability: Infinite scroll SEO; paginated component pages
- card: Card structure within grid; product, template, tool cards
- list: List layout vs grid; when to use each
- masonry: Masonry for varying heights (Pinterest-style)
- carousel: Carousel for slides/rotation; when grid is too dense
- hero-generator: Hero above; grid below for content sections
- products-page-generator: Product grid
- template-page-generator: Template grid
- features-page-generator: Feature grid
组件:网格布局
指导同级多列内容展示的网格布局设计。网格可展示多个同等重要的项目,节省空间且易于浏览。适用于产品、模板、工具、功能、博客索引和画廊。
调用时:首次使用时,如有帮助,可用1-2句话说明该技能涵盖的内容及其重要性,然后提供主要输出。后续使用或用户要求跳过时,直接提供主要输出。
何时使用网格
| 使用网格的场景 | 使用列表的场景 |
|---|
| 视觉内容(图片、缩略图) | 文字密集;按标题浏览 |
| 项目间同等重要 |
紧凑;项目多;信息密集 |
| 产品、模板、画廊、功能 | 博客索引、文档、搜索结果 |
| 浏览、发现 | 阅读、扫描 |
列表布局请参见列表;网格内卡片结构请参见卡片。
网格结构
项目间间距一致 |
|
项目 | 等大或按比例缩放 |
|
响应式 | 移动端1列 → 桌面端2-4列 |
实现方式
- - CSS网格:repeat(auto-fill, minmax(min, 1fr)) 或 repeat(auto-fit, minmax()) 实现流式列
- 断点:例如,1列 <768px;2列 768-1024px;3-4列 >1024px
- 一致性:项目间内边距、宽高比相同;卡片结构请参见卡片
最佳实践
| 原则 | 实践 |
|---|
| 同级层级 | 项目间竞争平等;无单个主导项目 |
| 尺寸一致 |
网格内卡片/项目尺寸相同 |
|
间距一致 | 统一间距(如16px、24px) |
|
无布局偏移 | 为图片预留空间;避免CLS |
响应式设计
- - 移动端:单列;全宽项目
- 平板端:2列;触摸目标 ≥44×44px
- 桌面端:3-4列;支持悬停状态
无限滚动
若在网格中使用无限滚动:爬虫无法访问滚动加载的内容。对于SEO关键内容,请提供分页组件页面。搜索引擎友好实现请参见站点可爬取性。
相关技能
- - 站点可爬取性:无限滚动SEO;分页组件页面
- 卡片:网格内卡片结构;产品、模板、工具卡片
- 列表:列表布局与网格布局;各自适用场景
- 瀑布流:不同高度的瀑布流布局(Pinterest风格)
- 轮播:幻灯片/旋转轮播;网格过于密集时的替代方案
- 英雄区生成器:上方英雄区;下方内容区域网格
- 产品页面生成器:产品网格
- 模板页面生成器:模板网格
- 功能页面生成器:功能网格