【发布时间】:2013-11-19 06:05:25
【问题描述】:
我有两个尺寸相同的 div。一个 div 放置在另一个上。每当我需要反向时,我为另一个 div 分配了 z-index。它在 chrome 中运行良好。但在 Internet Explorer 中,z-index: -1 元素被完全隐藏。为什么会这样?我用最新的 Internet Explorer 10 对此进行了测试。你们之前有没有发生过这种情况?
【问题讨论】:
-
嗯,你对一个负 z-index 的元素有什么期望呢? negative 索引意味着,它位于父元素的后面(如果没有在其上声明 z-index 的特定值) - 因此它当然是完全隐藏的。
-
旧 IE 版本确实存在
z-index的问题。较新的 IE 版本应该没问题,但是如果您处于兼容模式或怪癖模式,您可能仍然会得到旧式的行为。你能确认你的浏览器是什么模式吗? (使用 F12 调出开发工具一探究竟) -
据说MSDN: "
... A positive value positions the element above text that has no defined z-index, and a negative value positions it below. ..."
标签: html css internet-explorer google-chrome cross-browser