通过叠加层与滤镜组合提升前景对比度。
亮色/暗色图片源可根据主题模式切换。
通过叠加层与滤镜组合提升前景对比度。
亮色/暗色图片源可根据主题模式切换。
通过叠加层与滤镜组合提升前景对比度。
亮色/暗色图片源可根据主题模式切换。
通过叠加层与滤镜组合提升前景对比度。
亮色/暗色图片源可根据主题模式切换。
通过叠加层与滤镜组合提升前景对比度。
亮色/暗色图片源可根据主题模式切换。
通过叠加层与滤镜组合提升前景对比度。
亮色/暗色图片源可根据主题模式切换。
通过叠加层与滤镜组合提升前景对比度。
亮色/暗色图片源可根据主题模式切换。
通过叠加层与滤镜组合提升前景对比度。
亮色/暗色图片源可根据主题模式切换。
通过叠加层与滤镜组合提升前景对比度。
亮色/暗色图片源可根据主题模式切换。
通过叠加层与滤镜组合提升前景对比度。
亮色/暗色图片源可根据主题模式切换。
通过叠加层与滤镜组合提升前景对比度。
亮色/暗色图片源可根据主题模式切换。
通过叠加层与滤镜组合提升前景对比度。
亮色/暗色图片源可根据主题模式切换。
主要关注点:主题感知图片源与叠加层对比控制。
以下 YAML 即当前页面正在使用的完整 frontmatter,可直接复制用于复现同样效果。
---
layout: home
hero:
name: "单一背景"
text: "图片"
tagline: "媒体背景,支持主题感知图片源与叠加层控制。"
background:
type: image
image:
light: "https://images.unsplash.com/photo-1552664730-d307ca884978?auto=format&fit=crop&w=1800&q=80"
dark: "https://images.unsplash.com/photo-1519389950473-47ba0277781c?auto=format&fit=crop&w=1800&q=80"
size: cover
position: center
actions:
- theme: brand
text: "视频案例"
link: /zh-CN/hero/matrix/backgroundSingle/video
- theme: outline
text: "图层案例"
link: /zh-CN/hero/matrix/layers/level2ThreeLayers
features:
- title: "叠加层控制"
details: "通过叠加层与滤镜组合提升前景对比度。"
- title: "主题同步"
details: "亮色/暗色图片源可根据主题模式切换。"
---图片背景支持主题感知的图片源,并可通过叠加层增强文本对比。
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
type | string | - | 背景类型,设为 image |
image.src | string | - | 通用图片源(无主题区分) |
image.light | string | - | 亮色主题图片源 |
image.dark | string | - | 暗色主题图片源 |
image.size | string | cover | 背景尺寸 |
image.position | string | center | 背景位置 |
image.repeat | string | no-repeat | 背景重复 |
image.blur | number | - | 模糊程度(像素) |
image.scale | number | - | 缩放比例 |
image.opacity | number | - | 透明度(0-1) |
| 值 | 说明 |
|---|---|
cover | 覆盖整个区域,可能裁剪图片 |
contain | 完整显示图片,可能留白 |
auto | 图片原始尺寸 |
100% 100% | 拉伸填满 |
| 自定义 | 如 50%、300px |
| 值 | 说明 |
|---|---|
center | 居中 |
top / bottom | 顶部 / 底部 |
left / right | 左侧 / 右侧 |
| 组合 | 如 center top、left center |
| 百分比 | 如 50% 25% |
---
layout: home
hero:
name: "单一背景"
text: "图片"
tagline: "媒体背景,支持主题感知图片源与叠加层控制。"
background:
type: image
image:
light: "https://images.unsplash.com/photo-1552664730-d307ca884978?auto=format&fit=crop&w=1800&q=80"
dark: "https://images.unsplash.com/photo-1519389950473-47ba0277781c?auto=format&fit=crop&w=1800&q=80"
size: cover
position: center
actions:
- theme: brand
text: "视频案例"
link: /zh-CN/hero/matrix/backgroundSingle/video
features:
- title: "叠加层控制"
details: "通过叠加层与滤镜组合提升前景对比度。"
- title: "主题同步"
details: "亮色/暗色图片源可根据主题模式切换。"
---hero:
background:
type: image
image:
src: "/images/hero-bg.jpg"
blur: 8 # 8像素模糊hero:
background:
type: image
image:
src: "/images/hero-bg.jpg"
scale: 1.1 # 放大 10%hero:
background:
type: image
image:
src: "/images/hero-bg.jpg"
opacity: 0.7 # 70% 不透明度hero:
background:
type: image
image:
light: "/images/hero-light.jpg"
dark: "/images/hero-dark.jpg"
size: cover
position: center center
repeat: no-repeat
blur: 2
opacity: 0.95hero:
background:
type: image
image:
src: "/images/hero-bg.jpg"
size: cover
position: centerhero:
background:
type: image
image:
src: "/images/pattern.png"
size: 100px 100px
repeat: repeat
opacity: 0.1图片源支持以下格式:
| 格式 | 说明 |
|---|---|
| 绝对 URL | https://example.com/image.jpg |
| 相对路径 | /images/hero.jpg(相对于 src/public/) |
| 本地资源 | 自动通过 resolveAssetWithBase 解析 |
# 远程图片
image:
src: "https://images.unsplash.com/photo-xxx"
# 本地图片(位于 docs/src/public/images/)
image:
src: "/images/hero-bg.jpg"
# 主题区分
image:
light: "/images/hero-light.jpg"
dark: "/images/hero-dark.jpg"