【发布时间】:2017-06-28 18:27:26
【问题描述】:
我希望 gui 位于海报之上。两个元素都必须有固定的位置。如果我将 gui 位置设置为绝对位置,它工作正常,但固定不起作用。
#gui {
width: 250px;
height: 50px;
position: fixed; // If I change to absolute then it works.
background-color: green;
}
#poster {
width: 250px;
height: 250px;
position: fixed;
background-color: red;
z-index: -1;
}
<div id='gui'>
<div id='poster'></div>
</div>
https://jsfiddle.net/pfpj03f5/
为什么这不起作用?在#gui 上将 z-index 设置为正数也不起作用。
【问题讨论】:
-
你必须让 div 独立,否则它将无法工作..