css 位置属性是否影响 z-index 的优先级?
我已经在 stackoverflow 上阅读了几个有关 z-index 的问题/文章,但我仍然无法解决网页上 z-index 属性的最后一个问题。
简单的问题: 具有 position:absolute
的元素是否始终与具有 position:relative
的元素重叠,无论其 z-index 的值如何?
我需要强制具有 position:relative;z-index:50
的元素与 position:abosolute;z-index:5;
重叠。如果有必要的话我什至会使用脚本。
有一个网页存在该问题: 示例页面
注意:该网页高度基于z-index,并且有很多不优雅的CSS解决方案(粘性页脚,背景重复)。我几乎可以正常工作,但正如您所看到的,
具有相对位置,并且具有负下边距以与页脚重叠。但页脚 () 具有绝对位置,并且无论 z-index 较低,它都会与 mainConetnet 重叠。
I have read severals questions/articles about z-index on stackoverflow, but I am still unable to solve last problem with z-index property on my webpage.
The simple question:
Does element with position:absolute
always overlap the element with postion:relative
, no matter of value of their z-index?
I need to force element with position:relative;z-index:50
to overlap the element with postion:aboslute;z-index:5;
. I would even use script if necessary.
There is webpage with that issue: sample page
Note: That webpage is highly based on z-index, and there is a lot of not elegant css solutions (sticky footer, background repeat). I it's almost working but as you can see, the <div id="mainContent"> some text </div>
have position relative and have negative bottom margin to overlap the footer. But the footer (<div id="footerFixWrapper"></div>
) have absolute postion, and its overlaps mainConetnet no matter it have lower z-index.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来好像 div 存在于不同的堆叠上下文中。在这种情况下,z-index 不会影响彼此之间的关系。
CSS-Discuss Wiki 有详细信息: http://css-discuss.incutio.com/wiki/Overlapping_And_ZIndex
It looks as if the divs exist in different stacking contexts. In this situation, z-index will not affect either in relation to each other.
CSS-Discuss Wiki has the details: http://css-discuss.incutio.com/wiki/Overlapping_And_ZIndex