background
英 [ˈbækgraʊnd] 美 [ˈbækˌɡraʊnd]
n.(画等的)背景;底色;背景资料;配乐
复数: backgrounds
attachment
英 [əˈtætʃmənt] 美 [əˈtætʃmənt]
n.(用电子邮件发送的)附件,附属物;依恋,依附;扣押财产<法>逮捕,扣押(人,财产)
复数: attachments
css background-attachment属性 语法
background-attachment属性怎么用?
background-attachment属性需要和background-image属性一起使用,用来设置背景图像是否固定或者随着页面的其余部分滚动。可设置:scroll(背景图相对元素固定),fixed(背景图相对于视口固定)、ocal(背景图相对于元素内容固定)。
作用:background-attachment 属性设置背景图像是否固定或者随着页面的其余部分滚动。
说明:
scroll 默认值。背景图像会随着页面其余部分的滚动而移动。
fixed 当页面的其余部分滚动时,背景图像不会移动。
loca 背景图像相对于元素的内容固定。当元素的内容滚动时,背景图像总是要跟着内容一起移动
inherit 规定应该从父元素继承 background-attachment 属性的设置。
注释:所有浏览器都支持 background-attachment 属性。
css background-attachment属性 示例
<html>
<head>
<style type="text/css">
body
{
background-image:url('http://img.php.cn/upload/article/000/005/656/5af270fd37755429.jpg');
background-repeat:no-repeat;
background-attachment:fixed
}
</style>
</head>
<body>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
<p>图像不会随页面的其余部分滚动。</p>
</body>
</html>点击 "运行实例" 按钮查看在线实例
热门推荐
- html5紫色怎么加深_html5用CSS调color或background的RGB加深紫色【加深】
- css浮动导致背景图位置偏移怎么办_检查background-origin与padding并使用clearfix稳定背景包裹
- css背景图模糊看不清如何处理_css背景模糊问题可用background-size优化
- css背景图需要慢慢移动营造景深效果如何做_利用background-position动画完成平移
- css表格首行背景色渐变如何实现_使用::first-row和background-color
- css多列列表隔行不同背景色如何实现_使用:nth-child和background-color