CSS小技巧:粘滞定位+z-index
作者:互联网
页面只能容纳一个块级元素时,蓝色块会被隐藏
下滑滚动条,蓝色块逐渐出现
代码
<!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 type="text/css">
.pink {
width: 200px;
height: 200px;
background-color: pink;
}
.lightblue {
width: 200px;
height: 100px;
bottom: 100px;
z-index: -1;
position: sticky;
background-color: lightblue;
}
</style>
</head>
<body>
<div class="pink"></div>
<div class="lightblue"></div>
<div class="pink"></div>
<div class="lightblue"></div>
<div class="pink"></div>
</body>
</html>
标签:pink,index,color,100px,height,粘滞,CSS,200px 来源: https://www.cnblogs.com/rfcaTheshy/p/16226514.html