z-index是强制元素定位在另一个元素之上的唯一方式,如果没有其他方法吗? [英] Is z-index the only way to force an element to be positioned over top of another, if not what other methods are there?

查看:392
本文介绍了z-index是强制元素定位在另一个元素之上的唯一方式,如果没有其他方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个地图的应用程序,有一个div在角落里有一些东西。你可以点击这张地图,在一个小窗口中提出一些信息。在某些情况下,窗口被角落里的div覆盖。

I'm working on an application with a map and there is a div in the corner with some stuff in it. You can click on this map to bring up some information in a little window. The window is, in some cases, being covered by the div in the corner.

我想要相反的效果(窗口覆盖div)。我想这只是一个Z-index问题,但我不能得到它的工作。这是与IE7和阅读一点似乎z-index将无法工作,除非它在定位的元素内。

I want the opposite effect (window covers div). I figured this would simply be a z-index issue but I'm unable to get it to work. This is with IE7 and from reading up a bit it seems like z-index won't work unless it's inside of an element that is positioned.

元素似乎被正确定位,以使z-index正常工作,但我没有运气。我已经玩过通过Firebug添加样式,但没有任何运气,得到任何改变。窗口真的只是两个div,一个绝对定位一个和相对一个里面。

The elements seem to be positioned properly to get the z-index to work right but I'm having little luck. I've played around with adding styling via Firebug but haven't had any luck in getting anything to change. The window really is just two divs one absolutely positioned one and a relative one inside of it.

z-index是唯一可能是这里的问题还是有其他我不知道的东西?

Is the z-index the only thing that could be the problem here or is there something else I don't know about?

有没有其他方法来达到我想要的效果?我不能简单地隐藏的div通过jquery或东西,因为它的一部分应该是从在地图上打开的窗口后面可见。

Are there any other methods to achieve the effect I want? I cannot simply hide the div via jquery or something because part of it should be visible from behind the window that opens on the map.

推荐答案

p>您正在击打堆叠上下文错误

You are hitting the stacking context bug

http://therealcrisp.xs4all.nl/meuk/IE-zindexbug.html

在IE中每个定位的div都会创建一个新的堆叠上下文和防止z-index从不同的堆叠上下文来到其他人的顶部。

Every positioned div in IE will create a new stacking context and prevent z-index from diferent stacking contexts to come on top of others.

解决方案是让你想要的窗口在树中例如)和z-index值比覆盖你的窗口的其他div的所有父母的z-index更好。

The solution is to have the window you want on top up in the tree (into the body for example) and z-index value grater than z-index of all parents of the other div covering your window.

大量信息来理解这里的问题:
http://richa.avasthi.name / blogs / tepumpkin / 2008/01/11 / ie7-lessons-learned /

Extensive information to understand the problem here: http://richa.avasthi.name/blogs/tepumpkin/2008/01/11/ie7-lessons-learned/

这篇关于z-index是强制元素定位在另一个元素之上的唯一方式,如果没有其他方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆