【发布时间】:2017-05-31 17:24:01
【问题描述】:
我有以下代码(示例):
<div style="position: fixed">
<div id="AAA" style="position: absolute; background-color: green; z-index: 1">AAA</div>
</div>
<div style="position: relative">
<div id="BBB" style="position: absolute; background-color: red; z-index: 0">BBB</div>
</div>
对我来说,AAA div 应该显示在 BBB div 之上,因为:
- 它们都指定了位置,并且该位置支持 z-index
- AAA z-index (1) 高于 BBB z-index (0)
但在结果 HTML 中,BBB 显示在 AAA 之上。为什么?是否有任何文件描述了这种行为?
【问题讨论】:
-
移除定位的外部 div 和内部 div 的行为方式