【发布时间】:2014-04-26 01:30:17
【问题描述】:
我有两个 div-Tag,一个包含带有徽标的标题,另一个是信息 div。徽标应始终位于顶部,但实际上并非如此。
在两者上我都设置了 z-index。标头的 z-index 为 500,信息的 z-index 为 200,因为它应该位于徽标下方。
在 CSS 中:
div#logo { position:fixed; z-index: 500;}
div#markerInformation {position: absolute; z-index: 200;}
我得到的结果是相反的,你可以看到标志在信息下面:
要查看它的实际效果,您可以在这里查看:http://www.dominikamon.com/location/#f4ec7efc-d27a-4767-910b-f1af9a5547a8,4,52.231789,21.006128
注意div#logo的css定义是:
div#logo {
position: absolute;
z-index: 500;
}
但是一旦你向下滚动,就会有一个绑定到“滚动”的 jQuery 事件来设置位置:固定。
我已经查看了一些应该可以解决问题的帖子,例如:
- z-index not working with fixed positioning
- How does z-index and position fixed work together in css
- Position absolute has greater z-index than position fixed
也许我错过了其中一个要点,但我无法让它发挥作用?
【问题讨论】:
-
我仍然对您想要的输出感到困惑。是不是你不喜欢它的完成方式?或者您不希望徽标位于顶部。您究竟需要修复什么?
-
他们推荐使用“位置悬停” ~ 没有
position hover这样的东西。 developer.mozilla.org/en-US/docs/Web/CSS/position -
我希望将徽标固定在信息框上方,因此徽标应始终位于顶部
标签: html css css-position z-index