我想知道是否有修复。
<div id="div1" style="position: fixed; top:0; z-index:1; background:white;">
</div>
<div id="div2" style="position: absolute; top:100; z-index:0;">
<table>
<tr>
<td>
<input type="button" style="position: fixed; top:50; z-index:2;" />
</td>
</tr>
<tr>
<td>
some text that is longer than the width of the button
</td>
</tr>
</table>
</div>
我想要button在前面,<div id="div1">我想要buttonand<div id="div1">在前面 <div id="div2">。但我得到的是<div id="div1">按钮前面。
我假设原因是因为button嵌套在<div id="div2">that is behind 中<div id="div1">。除了重组,有人有什么想法吗?
我这样做是为了当我在页面上向下滚动时按钮将在文本顶部滚动。
文本比按钮的宽度长,所以我使用空白 div,这样您就不会看到按钮侧面出现额外的文本。
这个问题的答案证实了我的怀疑,但我想解决这个问题。基本上我想要button在前面div1和div1前面div2。