1.h5
底部输入框被键盘遮挡问题
如果你遇到h5
页面这个问题,当输入框在最底部,点击软键盘后输入框会被遮挡,可以如下解决问题:
var getHeight = $(document).height();
$(window).resize(function(){
if($(document).height() < getHeight) {
$('#footer').css('position','static');
}else {
$('#footer').css('position','absolute');
}
});
2.触屏即播放
$('html').one('touchstart',function(){
audio.play()
})
3.阻止旋转屏幕时自动调整字体大小
html, body, form, fieldset, p, div, h1, h2, h3, h4, h5, h6 {-webkit-text-size-adjust:none;}
4.主流网站布局
页面分为3个部分:页面的顶部header
,底部footer
,中间部分(侧栏side
和主要部分main
)。
下面代码展示:
<body>
// 页面层容器
<div id="container">
// 页面头部
<div id="header"></div>
// 页面主体
<div id="main">>
// 侧边栏
<div id="side">
</div>
</div>
// 页面底部
<div id="footer"></div>
</div>
</body>
设计页面样式代码如下:
<style type="text/css">
body{
font: 12px 微软雅黑;
margin: 0px;
text-align: center;
background: #fff;
}
// 页面层容器
#container {
width: 100%;
}
#header {
width: 800px;
margin: 0 auto;
height: 100px;
background: #FFCC99;
}
#main {
width: 800px;
margin: 0 auto;
height: 400px;
}
#side {
float: left;
width: 20em;
background: red;
padding: 15px 0;
}
#foot {
width: 800px;
margin: 0 auto;
height: 50px;
background: #00ffff;
}
</style>
效果图如下: