我想要一个灰色的覆盖物,除了selected
个以外的所有子元素.假设 struct 如下:
<div class="parent">
<!-- I have this subparent which is absolute. I cannot remove it... -->
<div class="subParent1">
<div class="subParent2">
<!-- This child I want to be above the OVERLAY, aka not greyed out -->
<div class="child selected">child</div>
<div class="child">child</div>
<div class="child">child</div>
</div>
</div>
<!-- This component is underneat subParent in the tree structure -->
<div class="grayOverlay"></div>
</div>
Here's an exact fiddle.也许,我可以使用伪元素来代替?
PS:我更新子代码,使其更加嵌套,与我的实际代码保持一致.