目的:实现向下滑动滚动条,实现简单图片覆盖切换。
效果图预览:
代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
* {
/*边框留白去掉*/
margin: 0;
padding: 0;
}
div {
/* 设置高度宽度 */
width: 100%;
height: 750px;
/* 覆盖,将图片最大限度展示出来 */
background-size: cover;
/* 图片居中 */
background-position: center;
/* 固定图片 */
background-attachment: fixed;
}
.box1 {
/* 设置图片路径 */
background-image: url(img/白鹿.png);
}
.box2 {
background-image: url(img/独角兽.png);
}
.box3 {
background-image: url(img/斑马.png);
}
</style>
</head>
<body>
<div class="box1">bailu</div>
<div class="box2"></div>
<div class="box3"></div>
</body>
</html>