我知道这标题可能比较抽象,
举个例子来讲,有这样一个页面:
<!doctype html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,minimum-scale=1">
<title>test</title>
<style>
.head{
position: fixed;
width: 100%;
height: 50px;
left: 0;
top: 0;
background: red;
}
.foot{
position: fixed;
width: 100%;
height: 50px;
left: 0;
bottom: 0;
background: blue;
}
.foot .input{
width: 300px;
height: 30px;
}
</style>
</head>
<body>
<div class="head"></div>
<div class="foot">
<input type="text" class="input">
</div>
</body>
</html>
在 ios Safari 中打开是这样子的:
这并没有什么问题,
问题是 当打开虚拟键盘之后 变成了这样子:
注意 顶部 .head 那个div 消失了~
不知道有没有人遇到过跟我一样的问题,求指教。
首先本人不支持在移动端开发过程中用fixed做导航定位。有的老板的苹果系统本身都不支持fixed,这回出一系列问题。至于页面整体往上移这种情况确实是存在的。