简体   繁体   English

如何在iOS网络应用中获得实际屏幕高度

[英]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.

相关问题 Phaser 3 - 如何在 HEIGHT_CONTROLS_WIDTH 上获得实际屏幕尺寸? - Phaser 3 - How to get actual screen size on HEIGHT_CONTROLS_WIDTH? 如何在Java Web应用程序中获取实际的移动设备屏幕尺寸? - How to get actual mobile device screen size in web applications, javascript? 如何获得1 td的实际高度? - How to get actual height of 1 td? 如何检索 HTML 元素的实际宽度和高度? - How do I retrieve an HTML element's actual width and height? 如何在 web 应用程序上获取键盘高度 - How to get keyboard height on a web app 如何在iOS上确定实际的视口宽度和高度 - How to determine actual viewport width and height on iOS 移动网络-打开键盘时如何获取屏幕的高度 - Mobile web - How to get the screen's height when the keyboard is open 如何确定HTML DOM元素的实际高度与CSS中指定的高度无关? - How do I determine the actual height of a HTML DOM element independent of the height specified in CSS? 如何获得 SVG 文本的实际高度(不是边界框高度) - How can I get the actual height of a SVG text (not the bounding box height) 当屏幕分辨率高度太小而不适合滚动div时,如何使可滚动div不向包含的div中增加高度? - How do I get scrollable div to not add height to containing divs when screen resolution height is too small to fit the scrolling div?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM