CSS background-attachment

css background-attachment 定义与用法

background-attachment设置背景图像是否固定或者随着页面的其余部分滚动。

默认值: scroll
继承: no
版本: CSS1
JavaScript 语法: object object.style.backgroundAttachment="fixed"

 

css background-attachment 浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要浏览器都支持background-attachment属性。

 

css background-attachment 属性值

说明
scroll 背景图片随页面的其余部分滚动。这是默认
fixed 背景图像是固定的
inherit 指定background-attachment的设置应该从父元素继承

 

css background-attachment 实例

如何指定一个固定的背景图像:

body{ 
    background-image:url('smiley.gif');
    background-repeat:no-repeat;
    background-attachment:fixed;
}

在线运行

 

相关文章

CSS 教程: CSS Background