1、body内有其他div的z-index比当前div的大。
2、z-index没有配合position使用
举例:实现全屏半黑状态
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div class="blackground"></div>
</body>
</html>
加定位前:
.blackground{
position: fixed;
background: rgba(0,0,0,0.59);
width:100%;
height:100%;
z-index: 1000;
}
加定位后:
.blackground{
position: fixed;
background: rgba(0,0,0,0.59);
width:100%;
height:100%;
top:0;
bottom: 0;
z-index: 1000;
}