CSS:background-attachment
From MDC
« CSS 参考
[编辑] 摘要
如果指定了 background-image ,那么 background-attachment 决定背景图像是在视角中固定的还是随滚动条滚动的。
- 默认值: scroll
- 应用于: 所有元素
- 可继承: 否
- 百分比: N/A
- 媒体:
Media:Visual - 计算值: 取指定值
[编辑] 语法
background-attachment: scroll | fixed | inherit
[编辑] 值
- scroll
- 如果设为
scroll,背景图片会随着包含它的区块一起滚动。 - fixed
- 如果设为
fixed,背景图片不会随着包含它的元素一直滚动,而是一直固定固定在屏幕的一个位置。
[编辑] 例子
body {
background-image: url("images/cartooncat.png");
background-position: bottom left;
background-attachment: fixed;
background-repeat: no-repeat;
}
[编辑] 规范
[编辑] 浏览器兼容性
| Browser | Lowest Version |
|---|---|
| Internet Explorer | 4 |
| Firefox | 1 |
| Netscape | 6 |
| Opera | 3.5 |
[编辑] 参见
background,
background-attachment,
background-color,
background-image,
background-position,
background-repeat