Internet Explorer z 索引错误?
如何将一个元素重叠到 Internet Explorer 中相对定位的另一个元素上? Z-index 不起作用,它总是出现在相对定位元素的后面。
How do you overlap an element over another element that is positioned relatively in Internet Explorer? Z-index doesn't work, it always appears behind the relatively positioned element.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
看起来我在开玩笑,但我不是
Looks like I'm kidding, but I am not
您绝对不会尝试将某些内容放在组合框(选择标签)、iframe 或 Flash 影片上,对吧?
在这些情况下,z-index 是一个失败的原因。
否则您使用什么浏览器版本并且使用绝对定位?
You're not by any chance trying to put something over a combobox (select tag), iframe or flash movie right?
In those cases z-index is a lost cause.
Otherwise what browser version are you using and are you using absolute positioning?
我对这个问题感到非常痛苦,因为这个特定的解决方法与此无关。 这有点难以解释,所以我将尝试使用代码:
问题是,将父级的 z-index 设置为更高的值会将其移动到前台,而不是应有的位置。 我完全偶然发现了一个解决方案:我在其父元素之外复制了前景元素(id=third)。
值得一提的是,在我的原始代码中,元素没有 ID,因此我不会遇到 2 个元素共享同一个元素并使我的 HTML 无效的情况。
我认为可以安全地将这种奇怪的现象归类为另一个恰好对原始版本有所帮助的错误,但它确实有效,至少对我来说是这样。 希望有人觉得这很有用!
I had a real pain with this problem that this particular workaround wasn't relevant for. It's a little hard to explain so I'll try using code:
The problem is that setting the parent's z-index to a higher value would move it to the foreground instead of the back where its supposed to be. I stumbled upon a solution completely by accident: I made a copy of the foreground element (id=third) outside its parent.
Its worth mentioning that in my original code the elements don't have IDs so I don't suffer from 2 elements sharing the same one and invalidating my HTML.
I think its safe to classify this weirdness as another bug that happens to help with the original, but it works, at least for me. Hope somebody finds this useful!
创建并在您想要放在顶部的元素上设置一个额外的透明背景图像。 对我来说,它终于在 IE8 中工作了。 SAS:
Create and then set an additional transparent background image on the element you want to have on top. For me it finally worked in IE8. SASS:
我想指出的是,如果您使用 IE8 及以下版本,它不支持 CSS3 过滤器。 这是我的问题。
我正在使用:
无论我将位置或 z 索引设置为什么,您都看不到其他图层,因为它会在该图层上造成完整的遮罩(而不是从透明变为黑色,然后再次透明)。
通过删除仅适用于 IE8 的 CSS3 过滤器,我能够解决我的问题。
希望这可以帮助遇到同样问题的人。
I wanted to note that if you are using IE8 and below, it does not support CSS3 filters. This was my issue.
I was using:
No matter what I set my position or z-index to, you could not see the other layer because it was causing a complete mask over that layer (instead of going from clear to black and to clear again).
By removing the CSS3 filter for just IE8, I was able to solve my problem.
Hope this helps someone who runs into the same issue.
我在 html 中遇到了同样的问题,其中许多重复的相对定位 div 阻塞了绝对定位 div 的视图。 我已经成功使用过 www.brenelz.com 提供的解决方法,但在这种情况下不起作用。 所以,以下内容对我有用:
我从我首先提到的那些 div 中删除了相对定位,然后添加了一个 CSS 以在悬停时将这些 div 打开相对位置。 让我向您展示代码:
之前:
之后:
这样该 div 的其他“姐妹”将保持正常定位,并且不会干扰布局。
这对我来说非常有效! 我希望它也对你有帮助。
I had the same problem in an html where many repeated relative positioned divs were blocking absolute positioned div's view. The workaround provided by www.brenelz.com, that I've already used with success wasn't working in this case. So, the following worked for me:
I removed the relative positioning from those divs I've mentioned first, then added a CSS to turn those divs on relative when hover. Let me show you the code:
Before:
After:
This way the others 'sisters' of that div stay with normal positioning and don't interfere with the layout.
It worked very well for me! I hope it helps you too.