CSS3 background-attachment:属性

来源:互联网 发布:java公司贷款培训骗局 编辑:程序博客网 时间:2024/04/25 03:55

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{ margin: 0px; padding: 0px; box-sizing: border-box;}
pre{ padding: 10px; font-size: 18px; position: fixed;}
article{ width: 1000px; margin: auto;}
article div{ width: 100%; height: 600px; box-shadow: 0px 0px 8px 2px gray;}
article div img{ width: 100%;}
.bg_img1{ background: url(http://img.daimg.com/uploads/allimg/120225/3-120225130605612.jpg) no-repeat; background-size: cover; background-attachment:  fixed;}
.bg_img2{ background: url(http://img.daimg.com/uploads/allimg/140718/3-140GR33143.jpg) no-repeat; background-size: cover; background-attachment:  fixed;}
.bg_img3{ background: url(http://img.daimg.com/uploads/allimg/120405/3-120405120PL31.jpg) no-repeat; background-size: cover; background-attachment:  fixed;}
.bg_img4{ background: url(http://img.daimg.com/uploads/allimg/120224/3-12022421310L04.jpg) no-repeat; background-size: cover; background-attachment:  fixed;}
</style>
</head>
<body>
<pre>
background-attachment :定义背景图片随滚动轴的移动方式
取值: scroll | fixed | inherit
scroll: 随着页面的滚动轴背景图片将移动
fixed: 随着页面的滚动轴背景图片不会移动
inherit: 继承初始值: scroll
继承性: 否
适用于: 所有元素
</pre>
<article>

<div ><img src="http://img.daimg.com/uploads/allimg/120224/3-120224210UR44.jpg"/></div>
<div class="bg_img1"></div>

<div ><img src="http://img.daimg.com/uploads/allimg/140905/3-140Z51GT7.jpg"/></div>
<div class="bg_img2"></div>

<div ><img src="http://www.daimg.com/uploads/allimg/120224/3-120224124141C4.jpg"/></div>
<div class="bg_img3"></div>

<div ><img src="http://img.daimg.com/uploads/allimg/120224/3-120224144215557.jpg"/></div>
<div class="bg_img4"></div>

</article>
</body>
</html>


1 0