<!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>
.a,
.b {
width: 500px;
height: 500px;
}
.a {
background: #000;
position: relative;
z-index: 20;
}
.b {
background: red;
position: fixed;
top: 20px;
z-index: 10;
}
.c {
width: 100px;
height: 100px;
background: green;
position: fixed;
top: 30px;
z-index: 990;
}
</style>
</head>
<body>
<div class="a"></div>
<div class="b">
<div class="c"></div>
</div>
</body>
</html>
正常html页面会显示.a 元素 黑色 因为z-index设置最高。但是在微信小程序组件中是用slot标签插入.c的位置 会导致.b层级不生效