我有一个父div,它的位置是固定的。我试图做的是在页面模糊时突出显示子div1,但整个父div都会突出显示。在阅读了很多帖子之后,发现父div会覆盖z-index,而子元素的z-index没有意义,所以我卡在这里不知道如何解决。
如果无法解决此问题,是否有人可以帮我找到解决方案?
如果无法解决此问题,是否有人可以帮我找到解决方案?
![enter image description here](https://istack.dev59.com/PJnJY.webp)
<div id="container">
<div class="child">Something</div>
<div class="child behind_parent">Something else</div>
<div class="child">Something else entirely</div>
<div id="parent"></div>
</div>
#container {
position: fixed;
padding: 10px;
}
#parent {
background: orange;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1;
}
.child {
position: relative;
background: red;
margin: 5px;
z-index: 2;
}
.behind_parent {
z-index: 0;
}
没有确切了解你的标记语言是什么,你可以尝试以下方法:
#parent {
position: fixed;
...
}
#child {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
...
}