How to calculate height of viewable area (i.e., window height minus address & bookmark bars) in mobile Safari for web app?

后端 未结 4 1152
后悔当初
后悔当初 2020-12-14 08:12

What is the right way to calculate how much viewable space is available on mobile Safari? By viewing area, we mean the amount of the screen actually available to a web app,

4条回答
  •  死守一世寂寞
    2020-12-14 09:03

    I know this is 5 years old post, but this problem still persists as i can tell. My workaround: Use a HTML Element on the page which is styled with CSS: .el{ height:100vh; } and retrieve the height in pixel to Javascript by using jQuery: $('.el').height();

    If you don't have a practical use for such a element you might create one on the fly for the sole purpose of masuring the viewport:

    var vh = $('
    "').appendTo('body').height(); $('body div:last-child').remove();

提交回复
热议问题