background-attachment简介
background-attachment属性在CSS背景中是比较常用的,本文将带你深入理解background-attachment属性的各个方面,包括它的语法、取值、作用和浏览器兼容性,最后附上background-attachment的实例,希望能够对你有所帮助。
background-attachment定义和用法
background-attachment:<attachment> [ , <attachment> ]*
<attachment> = fixed | scroll | local
默认值:scroll
适用于:所有元素
继承性:无
动画性:否
计算值:指定值
background-attachment属性值
- fixed:
- 背景图像相对于窗体固定。
- scroll:
- 背景图像相对于元素固定,也就是说当元素内容滚动时背景图像不会跟着滚动,因为背景图像总是要跟着元素本身。但会随元素的祖先元素或窗体一起滚动。
- local:
- 背景图像相对于元素内容固定,也就是说当元素随元素滚动时背景图像也会跟着滚动,因为背景图像总是要跟着内容。(CSS3)
background-attachment说明
设置或检索背景图像是随对象内容滚动还是固定的。必须先指定background-image属性。
- 对应的脚本特性为backgroundAttachment。
来源:http://caibaojian.com/css3/properties/background/background-attachment.htm