示例代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<meta name="apple-touch-fullscreen" content="YES" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<script src="http://s.thsi.cn/js/m/js/zepto.min.js"></script>
<title>ios_inputFixedBug</title>
<style type="text/css">
*{margin: 0;padding: 0;}
header{
position:fixed;/*"高度坍塌":fixed元素的高度会被忽略不计*/
height: 50px;
left: 0;
right: 0;
top: 0;
}
main{
position: absolute;/* main绝对定位,进行内部滚动 */
top:50px;
bottom: 40px;/*防止footer遮挡main内容*/
overflow-y: scroll;/*使之可以滚动*/
-webkit-overflow-scrolling: touch;/* 增加该属性,可以增加弹性 */
background-color: #f1a456;
width: 100%;
}
main .content{
height: 1000px;
}
footer{
position: fixed;
height: 40px;
left: 0;
right: 0;
bottom: 0;
}
footer input{height: 40px;width: 80%;}
</style>
</head>
<body>
<!--fixed定位-->
<header>头部</header>
<!-- 可以滚动的区域 -->
<main>
<div id="content">
ss
</div>
</main>
<footer id="send">
<input type="text" placeholder="请输入内容" style="text-indent: 5px;">
</footer>
<script type="text/javascript">
var str="";
for(var i=0; i<100; i++){
str += "内容区域(可滚动)"+ i + "<br/>";
}
$('#content').html(str);
</script>
</body>
</html>