具体要求:
1:图片不随着浏览器滚动而滚动
2:背景图尺寸不随浏览器缩放而变化,浏览器缩放的在小,图片还是原来的尺寸
具体展示,一张图片做首页,图片上放一些内容,并给内容做动画,图片的要求如上
代码实现如下:其中图片的路径要重新设置
<!DOCTYPE html>
<html>
<head>
<title> ... </title>
<meta charset="utf-8"/>
<meta name="HSW" content="">
<meta name="Keywords" content="">
<style>
.bgImg {
width:100%;
height:1080px;
background-color:#FFF;
background-image:url("1.jpg");
background-size: 100%;
background-repeat:no-repeat;
background-position:0px 0px;
background-attachment:fixed;
position:relative;
top:0px;
left:0px;
}
.space {
width:100%;
height:1000px;
border:3px solid red;
}
body {
background-image:url("1.jpg");
background-size: 100%;
background-repeat:no-repeat;
margin:0px;
padding:0px;
}
.header_all {
width:100%;
height:60px;
border:1px solid green;
position:absolute;
top:0;
left:0;
}
.right,.left {
position:absolute;
border:1px solid black;
width:50%;
height:1000px;
top:60px;
left:0px;
}
.left {
left:953px;
}
</style>
</head>
<body>
<!--第一页面的开始-->
<div class="bgImg">
<div class="header_all"></div>
<div class="right">1</div>
<div class="left">2</div>
</div>
<!--第一页面的结束-->
<div class="space">3</div>
</body>
</html>