我需要放置一个 <input>
在 <div>
里面这样当用户滚动时,<input>
位置保持相对于屏幕。我试过relative
和 absolute
与 position:
,但它们都不是相对于屏幕,而是相对于页面大小。
.console {
position: absolute;
right: 0px;
background-color: #fff;
width: 300px;
height: 600px;
border: 1px solid black;
overflow-y: auto;
}
.run {
position: absolute;
bottom: 0px;
width: 295px;
}
<div class='console' height='600'>
<input class='run' type='text' placeholder='I want this to be relative to the bottom of screen' />
</div>
代码片段显示了 <input>
停留在页面底部;我需要它位于用户屏幕的底部。最简单的方法是什么?
最佳答案
我使用了 position: fixed;
并且成功了。
关于javascript - 如何将输入定位在屏幕底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55104302/