简体   繁体   English

父级div类的z-index高于子级

[英]parent div class higher z-index than children

I wish to lay over a pattern indicating that an element is inactive. 我希望覆盖一个指示元素处于非活动状态的模式。

li .inactive {
   background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAFUlEQVQImWNgQALTGgr+k8phYGAAAFSlChVXUdguAAAAAElFTkSuQmCC) repeat;
}

This is a transparent png with a cross pattern: ///// so contents below can be semi-visible. 这是带有十字图案的透明png://///,因此下面的内容可以是半可见的。

The problem is that since the children elements are within, they are not really covered by the background image; 问题在于,由于子元素位于其中,因此背景图像并未真正覆盖它们。 its just seems that they are covered. 它只是似乎被覆盖了。 Its particularly ineffective on images with white areas. 它对带有白色区域的图像特别无效。

So I tried using a higher z-index for a parent and lower for a child??? 所以我尝试为父母使用较高的z-index,为孩子使用较低的z-index?

li .inactive {
     z-index: 9999;
}
li .inactive * {
     z-index: -1;
}

Any ideas? 有任何想法吗?

z-index only works on positioned elements (position:absolute, position:relative, or position:fixed). z-index仅适用于定位的元素(position:absolute,position:relative或position:fixed)。

try setting your elements to position:relative , and then apply the z-index 尝试将元素设置为position:relative ,然后应用z-index

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM