瀑布流布局
Masonry Flow
Pinterest 风格的不等高卡片瀑布流布局,通过 CSS columns 或 masonry grid 实现自然流动的视觉效果,适合图片展示、作品集、社交媒体。
配色方案
Primary
#1a1a2e
Secondary
#f5f5f5
Accent 1
#e94560
Accent 2
#16c79a
Accent 3
#ffd460
Accent 4
#7579e7
提示词
硬性 + 软性提示词
一键复制并生成 瀑布流布局 风格界面。硬性提示词用于强约束一致性,软性提示词用于保留风格方向下的灵活实现。
硬性提示词
高一致性,严格执行风格规则
STYLEKIT_STYLE_REFERENCE
style_name: 瀑布流布局
style_slug: masonry-flow
style_source: /styles/masonry-flow
# Hard Prompt
请严格遵守以下风格规则并保持一致性,禁止风格漂移。
## 执行要求
- 优先保证风格一致性,其次再做创意延展。
- 遇到冲突时以禁止项为最高优先级。
- 输出前自检:颜色、排版、间距、交互是否仍属于该风格。
## Style Rules
# Masonry Flow (瀑布流布局) Design System
> Pinterest 风格的不等高卡片瀑布流布局,通过 CSS columns 或 masonry grid 实现自然流动的视觉效果,适合图片展示、作品集、社交媒体。
## 核心理念
Masonry Flow(瀑布流布局)是一种模仿砖墙砌筑方式的布局,卡片按列排列,高度不一,形成自然流动的视觉效果。
核心理念:
- 自然流动:内容高度由内容本身决定,无需强制等高
- 空间利用:最大化利用可视区域,减少留白浪费
- 视觉节奏:不规则高度创造有趣的视觉韵律
- 无限滚动:天然适合加载更多内容的交互模式
---
## Token 字典(精确 Class 映射)
### 边框
```
宽度: border-0
颜色: border-zinc-200
圆角: rounded-xl
```
### 阴影
```
小: shadow-sm
中: shadow-md
大: shadow-lg
悬停: hover:shadow-lg
聚焦: focus:shadow-md
```
### 交互效果
```
悬停位移: hover:-translate-y-1
过渡动画: transition-all duration-300
按下状态: active:scale-95
```
### 字体
```
标题: font-semibold tracking-tight
正文: font-sans
```
### 字号
```
Hero: text-3xl md:text-4xl lg:text-5xl
H1: text-2xl md:text-3xl
H2: text-xl md:text-2xl
H3: text-lg md:text-xl
正文: text-sm md:text-base
小字: text-xs md:text-sm
```
### 间距
```
Section: py-8 md:py-12 lg:py-16
容器: px-4 md:px-6 lg:px-8
卡片: p-4 md:p-5
```
---
## [FORBIDDEN] 绝对禁止
以下 class 在本风格中**绝对禁止使用**,生成时必须检查并避免:
### 禁止的 Class
- `rounded-none`
- `border-2`
- `border-4`
- `border-8`
- `shadow-[`
- `font-black`
### 禁止的模式
- 匹配 `^border-[248]`
- 匹配 `^shadow-\[`
### 禁止原因
- `rounded-none`: Masonry Flow uses rounded corners (rounded-xl) for soft card aesthetics
- `border-4`: Masonry Flow uses borderless or very subtle borders
- `font-black`: Masonry Flow uses semibold weight, not black
> WARNING: 如果你的代码中包含以上任何 class,必须立即替换。
---
## [REQUIRED] 必须包含
### 按钮必须包含
```
rounded-lg
font-medium text-sm
transition-colors
```
### 卡片必须包含
```
break-inside-avoid
rounded-xl
overflow-hidden
bg-white
```
### 输入框必须包含
```
rounded-full
bg-zinc-100
border-0
focus:outline-none
focus:ring-2 focus:ring-zinc-900/10
transition-all
```
---
## [COMPARE] 错误 vs 正确对比
### 按钮
[WRONG] **错误示例**(使用了圆角和模糊阴影):
```html
<button class="rounded-lg shadow-lg bg-blue-500 text-white px-4 py-2 hover:bg-blue-600">
点击我
</button>
```
[CORRECT] **正确示例**(使用硬边缘、无圆角、位移效果):
```html
<button class="rounded-lg font-medium text-sm transition-colors bg-[#ff006e] text-white px-4 py-2 md:px-6 md:py-3">
点击我
</button>
```
### 卡片
[WRONG] **错误示例**(使用了渐变和圆角):
```html
<div class="rounded-xl shadow-2xl bg-gradient-to-r from-purple-500 to-pink-500 p-6">
<h3 class="text-xl font-semibold">标题</h3>
</div>
```
[CORRECT] **正确示例**(纯色背景、硬边缘阴影):
```html
<div class="break-inside-avoid rounded-xl overflow-hidden bg-white p-4 md:p-5">
<h3 class="font-semibold tracking-tight text-lg md:text-xl">标题</h3>
</div>
```
### 输入框
[WRONG] **错误示例**(灰色边框、圆角):
```html
<input class="rounded-md border border-gray-300 px-3 py-2 focus:ring-2 focus:ring-blue-500" />
```
[CORRECT] **正确示例**(黑色粗边框、聚焦阴影):
```html
<input class="rounded-full bg-zinc-100 border-0 focus:outline-none focus:ring-2 focus:ring-zinc-900/10 transition-all px-3 py-2 md:px-4 md:py-3" placeholder="请输入..." />
```
---
## [TEMPLATES] 页面骨架模板
使用以下模板生成页面,只需替换 `{PLACEHOLDER}` 部分:
### 导航栏骨架
```html
<nav class="bg-white border-b-2 md:border-b-4 border-black px-4 md:px-8 py-3 md:py-4">
<div class="flex items-center justify-between max-w-6xl mx-auto">
<a href="/" class="font-black text-xl md:text-2xl tracking-wider">
{LOGO_TEXT}
</a>
<div class="flex gap-4 md:gap-8 font-mono text-sm md:text-base">
{NAV_LINKS}
</div>
</div>
</nav>
```
### Hero 区块骨架
```html
<section class="min-h-[60vh] md:min-h-[80vh] flex items-center px-4 md:px-8 py-12 md:py-0 bg-{ACCENT_COLOR} border-b-2 md:border-b-4 border-black">
<div class="max-w-4xl mx-auto">
<h1 class="font-black text-4xl md:text-6xl lg:text-8xl leading-tight tracking-tight mb-4 md:mb-6">
{HEADLINE}
</h1>
<p class="font-mono text-base md:text-xl max-w-xl mb-6 md:mb-8">
{SUBHEADLINE}
</p>
<button class="bg-black text-white font-black px-6 py-3 md:px-8 md:py-4 border-2 md:border-4 border-black shadow-[4px_4px_0px_0px_rgba(255,0,110,1)] md:shadow-[8px_8px_0px_0px_rgba(255,0,110,1)] hover:shadow-none hover:translate-x-[2px] hover:translate-y-[2px] transition-all text-sm md:text-base">
{CTA_TEXT}
</button>
</div>
</section>
```
### 卡片网格骨架
```html
<section class="py-12 md:py-24 px-4 md:px-8">
<div class="max-w-6xl mx-auto">
<h2 class="font-black text-2xl md:text-4xl mb-8 md:mb-12">{SECTION_TITLE}</h2>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 md:gap-6">
<!-- Card template - repeat for each card -->
<div class="bg-white border-2 md:border-4 border-black shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] md:shadow-[8px_8px_0px_0px_rgba(0,0,0,1)] p-4 md:p-6 hover:shadow-[4px_4px_0px_0px_rgba(255,0,110,1)] md:hover:shadow-[8px_8px_0px_0px_rgba(255,0,110,1)] hover:-translate-y-1 transition-all">
<h3 class="font-black text-lg md:text-xl mb-2">{CARD_TITLE}</h3>
<p class="font-mono text-sm md:text-base text-gray-700">{CARD_DESCRIPTION}</p>
</div>
</div>
</div>
</section>
```
### 页脚骨架
```html
<footer class="bg-black text-white py-12 md:py-16 px-4 md:px-8 border-t-2 md:border-t-4 border-black">
<div class="max-w-6xl mx-auto">
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
<div>
<span class="font-black text-xl md:text-2xl">{LOGO_TEXT}</span>
<p class="font-mono text-sm mt-4 text-gray-400">{TAGLINE}</p>
</div>
<div>
<h4 class="font-black text-lg mb-4">{COLUMN_TITLE}</h4>
<ul class="space-y-2 font-mono text-sm text-gray-400">
{FOOTER_LINKS}
</ul>
</div>
</div>
</div>
</footer>
```
---
## [CHECKLIST] 生成后自检清单
**在输出代码前,必须逐项验证以下每一条。如有违反,立即修正后再输出:**
### 1. 圆角检查
- [ ] 搜索代码中的 `rounded-`
- [ ] 确认只有 `rounded-none` 或无圆角
- [ ] 如果发现 `rounded-lg`、`rounded-md` 等,替换为 `rounded-none`
### 2. 阴影检查
- [ ] 搜索代码中的 `shadow-`
- [ ] 确认只使用 `shadow-[Xpx_Xpx_0px_0px_rgba(...)]` 格式
- [ ] 如果发现 `shadow-lg`、`shadow-xl` 等,替换为正确格式
### 3. 边框检查
- [ ] 搜索代码中的 `border-`
- [ ] 确认边框颜色是 `border-black`
- [ ] 如果发现 `border-gray-*`、`border-slate-*`,替换为 `border-black`
### 4. 交互检查
- [ ] 所有按钮都有 `hover:shadow-none hover:translate-x-[2px] hover:translate-y-[2px]`
- [ ] 所有卡片都有 hover 效果(阴影变色或位移)
- [ ] 都包含 `transition-all`
### 5. 响应式检查
- [ ] 边框有 `border-2 md:border-4`
- [ ] 阴影有 `shadow-[4px...] md:shadow-[8px...]`
- [ ] 间距有 `p-4 md:p-6` 或类似的响应式值
- [ ] 字号有 `text-sm md:text-base` 或类似的响应式值
### 6. 字体检查
- [ ] 标题使用 `font-black`
- [ ] 正文使用 `font-mono`
> CRITICAL: **如果任何一项检查不通过,必须修正后重新生成代码。**
---
## [EXAMPLES] 示例 Prompt
### 1. 图片画廊
Pinterest 风格的图片瀑布流
```
Create a Pinterest-style photo gallery with masonry layout:
1. Use CSS columns for masonry: columns-2 md:columns-3 lg:columns-4
2. Cards with varying heights (aspect-[3/4], aspect-square, aspect-[4/5])
3. Each card: rounded-xl, overflow-hidden, shadow on hover
4. Image with lazy loading and hover scale effect
5. Optional overlay with title on hover
6. Filter tabs at top (All, Photos, Videos, etc.)
7. Load more button at bottom
All cards use break-inside-avoid, consistent gap-4
```
### 2. 作品集展示
设计师作品集的瀑布流布局
```
Create a designer portfolio with masonry flow:
1. Masonry grid with columns-1 md:columns-2 lg:columns-3
2. Project cards with different aspect ratios
3. Each card shows: project image, title, category tag
4. Hover effect: reveal project description
5. Mix of image cards and text-only cards
6. Category filter navigation
7. Smooth scroll to load more projects
Cards use break-inside-avoid, rounded-2xl, elegant shadows
```
### 3. 社交动态墙
社交媒体风格的内容流
```
Create a social media feed with masonry layout:
1. Masonry columns: columns-1 sm:columns-2 lg:columns-3
2. Mixed content cards: text posts, images, quotes, links
3. Each card has: avatar, username, timestamp, content, reactions
4. Image posts have varying aspect ratios
5. Text posts auto-height based on content
6. Hover to show action buttons (like, comment, share)
7. Infinite scroll loading indicator
Use break-inside-avoid, rounded-xl cards, subtle shadows
```软性提示词
保留风格方向,允许实现灵活
STYLEKIT_STYLE_REFERENCE
style_name: 瀑布流布局
style_slug: masonry-flow
style_source: /styles/masonry-flow
# Soft Prompt
保持整体风格气质即可,允许实现细节灵活调整,但不要偏离核心视觉语言。
## Style Signals
- 瀑布流
- Pinterest
- 不等高
- 图片墙
- 作品集
- gallery
## Prefer
- 使用 CSS columns 实现简单瀑布流 columns-2 md:columns-3 lg:columns-4
- 或使用 CSS Grid masonry(需浏览器支持)grid-rows-[masonry]
- 卡片添加 break-inside-avoid 防止内容断裂
- 统一卡片宽度,高度自适应内容
## Avoid
- 禁止强制所有卡片等高(失去瀑布流特色)
- 禁止卡片宽度不一致
- 禁止间距不统一
## Output Guidance
- 先保证整体风格识别度,再优化细节。
- 避免过度炫技,保持可读性与可维护性。设计哲学
Masonry Flow(瀑布流布局)是一种模仿砖墙砌筑方式的布局,卡片按列排列,高度不一,形成自然流动的视觉效果。
核心理念: - 自然流动:内容高度由内容本身决定,无需强制等高 - 空间利用:最大化利用可视区域,减少留白浪费 - 视觉节奏:不规则高度创造有趣的视觉韵律 - 无限滚动:天然适合加载更多内容的交互模式
必须做 / Do's
- +使用 CSS columns 实现简单瀑布流 columns-2 md:columns-3 lg:columns-4
- +或使用 CSS Grid masonry(需浏览器支持)grid-rows-[masonry]
- +卡片添加 break-inside-avoid 防止内容断裂
- +统一卡片宽度,高度自适应内容
- +保持列间距一致 gap-4 或 gap-6
- +添加加载动画和懒加载图片
- +响应式调整列数 columns-1 sm:columns-2 lg:columns-3
- +卡片使用 group 类,图片在 overflow-hidden 内 group-hover:scale-105 duration-700 ease-out(Confined Zoom,永不突破容器)
- +卡片悬浮:hover:-translate-y-1 hover:shadow-[0_15px_30px_rgba(0,0,0,0.08)](Subtle Elevation,轻盈不打断瀑布流视觉连贯性)
- +操作按钮 translate-y-4 opacity-0 group-hover:translate-y-0 group-hover:opacity-100 transition-all duration-300(Overlay Reveal,遮罩抽屉浮现)
- +filter 筛选按钮 duration-200 确保即时响应(Action Snappiness)
禁止做 / Don'ts
- -禁止强制所有卡片等高(失去瀑布流特色)
- -禁止卡片宽度不一致
- -禁止间距不统一
- -禁止忽略图片加载状态
- -禁止在小屏幕使用过多列数
- -禁止图片放大突破 overflow-hidden 容器(Confined Zoom 必须保持边界)
- -禁止卡片使用生硬的深色边框作为 hover 反馈(用阴影和位移代替)
- -禁止 hover 位移超过 -translate-y-1(过大的浮起会打断瀑布流视觉连贯性)
组件模板
组件预览
按钮
瀑布流风格的简洁按钮,带有 Subtle Elevation 和 Action Snappiness 效果
<button className="
px-5 py-2.5
bg-zinc-900 text-white
rounded-lg
font-medium text-sm
shadow-sm
hover:bg-zinc-700
hover:-translate-y-0.5
hover:shadow-[0_4px_12px_rgba(0,0,0,0.15)]
focus:outline-none focus:ring-2 focus:ring-zinc-900/30 focus:ring-offset-2
active:scale-[0.98] active:translate-y-0
transition-all duration-200
">
Load More
</button>全局样式
全局 CSS
/* Masonry Flow Global Styles */
/* CSS Columns based masonry */
.masonry-grid {
columns: 1;
column-gap: 1rem;
}
@media (min-width: 640px) {
.masonry-grid {
columns: 2;
}
}
@media (min-width: 1024px) {
.masonry-grid {
columns: 3;
}
}
@media (min-width: 1280px) {
.masonry-grid {
columns: 4;
}
}
/* Prevent card breaking */
.masonry-item {
break-inside: avoid;
margin-bottom: 1rem;
}
/* Card hover effects */
.masonry-item {
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.masonry-item:hover {
transform: translateY(-4px);
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}
/* Image loading placeholder */
.masonry-item img {
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
background-size: 200% 100%;
animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
/* Loaded state */
.masonry-item img.loaded {
background: none;
animation: none;
}兼容的视觉风格
试试搭配
瀑布流布局 是一种布局模式,可以与以下视觉风格搭配使用。
无障碍
无障碍评分
基于颜色对比度和排版可读性的 WCAG 2.1 合规分析。
综合评分
等级: B - 良好
对比度
| 场景 | 颜色 | 比率 | AA | AAA |
|---|---|---|---|---|
| Text on secondary background | /#18181b / #ffffff | 17.72:1 | ||
| Button primary | /#ffffff / #18181b | 17.72:1 | ||
| Text on accent 1 | /#18181b / #e94560 | 4.63:1 | ||
| Text on accent 2 | /#18181b / #16c79a | 8.16:1 | ||
| Text on accent 3 | /#18181b / #ffd460 | 12.52:1 | ||
| Text on accent 4 | /#18181b / #7579e7 | 4.76:1 |
可读性
分数
77/100
字号
text-sm md:text-base
字重
font-semibold tracking-tight
行高
default
评分基于 WCAG 2.1 标准。AA 级要求普通文本对比度 4.5:1、大文本 3:1;AAA 级要求普通文本 7:1、大文本 4.5:1。
IDE 集成
IDE 配置导出
下载 AI 编码助手的配置文件,使其按照此风格生成代码。
风格包
导出风格包
获取完整的可机器读取风格资源,包括 Design Tokens、Tailwind 预设、CSS 变量和 shadcn/ui 主题。
Metadata
Style metadata including version information
Design Tokens
Figma / Style Dictionary / Tokens Studio 兼容
Tailwind Preset
Tailwind CSS 主题预设,可直接在配置中引用
Global CSS
包含 CSS 变量和基础样式
shadcn Theme
shadcn/ui 主题配置
CSS Variables
纯 CSS 变量,适用于任何项目
SKILL.md
可加载到 Cursor / Claude Code / VS Code 的技能包