ie7 z-index bug...修复时遇到问题
我有 2 列(几行)的 div,如下所示:
<div class="odd">
<div class="desc"></div>
</div>
<div class="even">
<div class="desc"></div>
</div>
odd
和 even
类相对 z-index 为 1 且 desc
定位> 类的 z 索引为 5 进行绝对定位。它的设置使得奇数内的 desc 与右侧的偶数重叠, even
内的 desc
与左侧的 odd
重叠。
除了在 ie7
中之外,这都可以正常工作。 odd
中的 desc
显示为 even
下方。我尝试了几件事,我想出的唯一解决方案只是颠倒了我的问题,我将奇数设置为 2 的 z 索引,将偶数设置为 1 的 z 索引,但是那么偶数的 desc 就隐藏在奇数下面。
我希望这是有道理的。我基本上是在展示产品,当您将鼠标悬停在图像上时,旁边会弹出描述(在旁边的产品上,向左或向右表示偶数或奇数)。除了 ie8 之外,它工作正常。
有解决办法吗?
这里更新
的是CSS:
.even, .odd
{
padding:5px;
width:332px;
float:left;
position:relative;
}
.desc
{
height:300px;
padding:5px;
position:absolute;
top:30px;
z-index:5;
width:300px;
visibility:hidden;
}
.even:hover .desc, .odd:hover .desc
{
visibility:visible;
}
.even:hover .desc:hover, .odd:hover .desc:hover
{
visibility:hidden;
}
.even .desc
{
right:100%;
}
.odd .desc
{
left:100%;
}
I have 2 columns (several rows) of divs like this:
<div class="odd">
<div class="desc"></div>
</div>
<div class="even">
<div class="desc"></div>
</div>
the odd
and even
classes are positioned relatively with z-index of 1 and the desc
classes are positioned absolutely with a z-index of 5. Its set so that the desc
inside the odd
overlaps the even
to the right, and the desc
inside the even
overlaps the odd
to the left.
This works fine except in ie7
. the desc
from the odd
is showing as under the even
. I tried several things and the only solution I came up with just inverted my problem I set odd
to a z-index of 2 and even
to a z-index of 1 but then the desc from the even hides under the odd.
I hope this makes sense. I am basically showing products, when you hover over the image a description pops up to the side (over the product next to it, left or right for even or odd). Its working fine except for ie8.
Is there a fix?
update
here is the css:
.even, .odd
{
padding:5px;
width:332px;
float:left;
position:relative;
}
.desc
{
height:300px;
padding:5px;
position:absolute;
top:30px;
z-index:5;
width:300px;
visibility:hidden;
}
.even:hover .desc, .odd:hover .desc
{
visibility:visible;
}
.even:hover .desc:hover, .odd:hover .desc:hover
{
visibility:hidden;
}
.even .desc
{
right:100%;
}
.odd .desc
{
left:100%;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
父 z 索引始终优先于其子索引。这是 W3C 对该行为的官方定义。因此,如果您的 desc1 和 desc2 分别为 10 和 10 ,这并不重要。 400 作为 z-index 值,只要你的奇数类有 1,偶数有 2,偶数总是在顶部。
The parent z-index always takes precedence over its child's index. This is the official W3C definition of the behaviour. So it really doesn't matter if your desc1 and desc2 have 10 and resp. 400 as z-index value as long as your odd class have 1 and even has 2, even always will be on top.