示例工程 25-responsive-images

25-responsive-images/demo-02-object-fit/README.md

markdown · 0.3 KB

运行:object-fit 与比例

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

# demo-02-object-fit

同一张图,三种填充方式。

## 运行

直接打开 `index.html`。

## 观察

- `cover` 填满并裁切,最常用于封面
- `contain` 完整显示并留白,适合图表
- `fill` 拉伸变形,通常不是想要的效果
- 配合固定高度或 `aspect-ratio` 使用