CSS - z-index 无法正常工作
我在我的页面上使用 z-index(-不再需要链接-),但它无法正常工作:它没有将某些 div 置于所有其他 div 之上...
您可以通过单击以下之一来亲自查看它左侧或右侧栏中的项目。 然后,蒙版将淡入,但在其下方显示消息框。 我已经尝试了很多,但我就是无法让消息框显示在所有其他消息框之上...
我能做些什么来解决这个问题? [注意:下面的第二个问题! ]
如果你不想查看页面,消息框位于其他一些div中:
<div>
<div>
<div>message box</div>
</div>
</div>
CSS定位是这样的:
.window {
position: fixed;
left: 0px;
top: 0px;
z-index: 100;
}
我使用position:fixed,因为position:absolute在这里不是绝对的,div并没有与身体对齐,而是以某种方式与其他东西对齐。 有没有办法重新设置定位和绝对位置?
I'm using z-index on my page ( -link no longer needed- ), and it doesn't work properly: it doesn't place certain divs above all others...
You can see it yourself, by clicking one of the items in the left, or right bar.
Then, the mask will fade in, but show the message box, beneath it.
I've tried a lot, but I just can't get the message box to show above all others...
What can I do to fix this? [note: 2nd question below!]
If you don't want to check the page, the message box is located in some other divs:
<div>
<div>
<div>message box</div>
</div>
</div>
The CSS positioning is like this:
.window {
position: fixed;
left: 0px;
top: 0px;
z-index: 100;
}
I use position:fixed, because position:absolute is not absolute here, the div is not aligned to the body, but something else somehow.
Is there a way to reset the positioning and absolute position it again?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从我记事起,z 索引问题通常源于 z 索引元素的父元素未定位这一事实。兄弟姐妹父母应该有定位。
For as long as I can remember, z-index issues often come from the fact than the parents of the z-indexed elements are not positioned. Sibling parents should be positioned.
如果您使用的是 jquery,请检查 顶部Z Index Plug In,您可以在对象发生鼠标悬停事件时应用它,例如:
然后也使用 jquery 将位置更改为绝对位置,反之亦然:
If you're using jquery check the top Z Index Plug In, you can apply it when the object has a mouse over event like:
Then change the position to absolute with jquery also or viceversa:
如果您从 #leftbar 中删除 z-index ,它可以解决您的问题。位置并不重要,只要你有一个就行。
if you remove z-index from #leftbar it fixes your problem. The position should not matter, as long as you have one.