移动端web页面 基于根元素的absolute bottom在安卓下小键盘出现时会被顶起来

新手上路,请多包涵

如题,ios下正常
现在我已有的解决方案是js 计算出 视窗高度,然后给这个元素一个计算出的top值,可以解决
但是我想问问有没有纯css的方案
demo如下,需在手机内测试
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <meta name="format-detection" content="telephone=no" />
    <title></title>
    <style>
        .btm{
            position: absolute;
            bottom: 5px;
        }
    </style>
</head>
<body>
    <div style="border: 1px solid #ccc;height: 300px;">
        <input type="text" />
    </div>
    <div class="btm">bugbugbugbugbug</div>
</body>

</html>

阅读 2.4k
1 个回答

键盘出来,窗口的高度就改变了。
除非你把body的尺寸定死(试一下)

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题