[英]100% body height in landscape overflows due to button bar
考虑以下页面:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
html, body
{
padding: 0;
margin: 0;
height: 100%;
}
</style>
</head>
<body>
</body>
</html>
将其加载到iPhone上的野生动物园中。 页面以100%的高度呈现。 现在,将iPhone放到横向并向上拖动页面。 出现(底部)按钮栏,现在我们上下滚动页面,使按钮栏偏移内容。 页面高度不再是100%,按钮栏下方应显示的内容是可见的,并且垂直滚动条可见。
是否有可能消除这种烦恼并获得100%的真实身高?
如果是iPhone,请使用以下脚本将类添加到html
:
if((navigator.userAgent.match(/iPhone/i))) {
$('html').addClass('iphone');
}
然后尝试将其位置固定为固定,但仅当方向为横向时才如此,如下所示:
@media (orientation:landscape) {
html.iphone > body {
position: fixed;
bottom: 0;
width:100%;
height: 480px !important; /* pretty sure its 480px? */
}
}
最终通过在头部的meta
指令解决了这一问题,该指令使底部按钮栏的外观更具攻击性。 注意最后一部分( minimal-ui
)
<meta name="viewport"
content="width=device-width, initial-scale=1.0, user-scalable=no, minimal-ui">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.