我试图通过声明 position: Fixed;
来修复按钮,但它适用于整个页面。是否有任何解决方案可以将按钮固定为 height:200px
的 div。我想要做的是针对其父级的 div 高度固定的按钮。肯定会感谢任何帮助。
我这样做过
<div style="Height:200px; width:45%;">
<div style="position:fixed; top:100px; left:253px;">
<asp:Button ID="ReplyEventButton" runat="server" Text="Reply to this Ad" />
</div>
</div>
最佳答案
使用 position: absolute
而不是 fixed
。您的父 div 需要有 position: relative
。
<div style="height:200px; width:45%; position:relative;">
<div style="position: absolute; top:100px; left:253px;">
<asp:Button ID="ReplyEventButton" runat="server" Text="Reply to this Ad" />
</div>
</div>
关于javascript - 如何固定div按钮的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23868595/