[英]How do I get actual screen height in an iOS web app
I am trying to determine the actual screen height in iOS. 我试图确定iOS中的实际屏幕高度。
On a short page. 在一个短的页面上。 If I use the code below I get an incorrect size.
如果我使用下面的代码,我的大小不正确。
window.innerHeight
This will return 356 on my iPod touch. 这将在我的iPod touch上返回356。 This is screen height - URL bar.
这是屏幕高度 - 网址栏。 If I add a CSS rule to the container of my page then it returns the correct number 416.
如果我将CSS规则添加到我的页面的容器中,那么它将返回正确的数字416。
#container { min-height:600px; }
However, the problem with this solution is it adds a chunk of blank space at the bottom of some pages. 但是,此解决方案的问题是它在某些页面的底部添加了一大块空白区域。
I have tried to fix this by doing the following. 我试图通过执行以下操作来解决此问题。
$('#container ').css('height', '800px');
window.scrollTo(0, 1);
$('#container ').css({
'height' : window.innerHeight + 'px'
});
This doesn't work. 这不起作用。 It doesn't influence the page height at all and I am not sure why.
它根本不影响页面高度,我不知道为什么。 Has anyone solved this problem before?
有人解决过这个问题吗?
window.screen对象应包含您要查找的内容
window.screen.height
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.