完美的视差滚动
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>dome</title>
<style>
*{
margin:0;
padding: 0;
border: none;
}
html,body{
height:100%;
}
div{
height:100%;
text-align: center;
position: relative;
color: #66CC00;
font-size: 32px;
}
.bg{
background-attachment: fixed;
background-size: cover;
background-position:center;
background-repeat: no-repeat;
}
.bg1{
background-image: url("img/1.jpg");
}
.bg2{
background-image: url("img/2.jpg");
}
.bg3{
background-image: url("img/3.jpg");
}
</style>
</head>
<body>
<div class="bg bg1">第一部分</div>
<div class="bg">第二部分</div>
<div class="bg bg2">第三部分</div>
<div class="bg">第四部分</div>
<div class="bg bg3">第五部分</div>
<div class="bg">第六部分</div>
</body>
</html>
换下图片试下就ok!视差滚动就这样实现了