css写阴影被后边元素遮挡
如图,给div1设置阴影,最下边被下边的div2遮挡

<div class="list">div1</div>
<div class="list2">div2</div>
.list {
color: black;
width: 400px;
height: 300px;
margin: auto;
box-shadow: 0 0 15px 8px red;
}
.list2 {
color: #fff;
width: 400px;
height: 300px;
margin: auto;
background: black;
}
解决方法:
给设置阴影的元素设置定位,并设置高层级
.list {
color: black;
width: 400px;
height: 300px;
margin: auto;
box-shadow: 0 0 15px 8px red;
position: relative;
z-index: 100;
}
.list2 {
color: #fff;
width: 400px;
height: 300px;
margin: auto;
background: black;
}
阴影就出来啦