javascript - 如何将输入定位在屏幕底部?
问题描述
我需要在 a 中放置一个<input>
,<div>
以便当用户滚动时,该<input>
位置相对于屏幕保持不变。我试过relative
and absolute
with 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;
,效果很好。
推荐阅读
- python - AWS S3 同步方法 - 可以完全忽略修改过的文件吗?
- floating-point - 如何在系统verilog中获取实数/短实数的符号、尾数和指数
- powershell - 按行号分段读取文件
- swift - 如何在 UITabelViewCell 类中访问正确的单元格宽度?
- c# - 在发布时设置/获取 DeliveryTag RabbitMQ
- apache-kafka - 具有 Kafka 流的自定义状态存储 (RocksDb) 是否有保留策略?
- powershell - Get-Package 命令包含 xml 字符串 - 需要转换为 PSObject
- python - 应用函数将数组除以向量
- javascript - 如何判断一个特定模块是 CommonJS 模块还是 ES6 模块?
- c++ - 如何将 int** 转换为 void**?