html - Smartphone's Viewport Height without Browser UI (URL Bar) - Stack Overflow

community,I've made a one-screen page and have an issue with depicting it on a smartphone.100vh

community,

I've made a one-screen page and have an issue with depicting it on a smartphone. 100vh is calculated regardless of the Browser UI that takes space on the page, leading it to the situation where I do not have the entire content on the page, and I have ~60 pixels of scroll (to collapse the URL bar).

I tried different methods: dvh, svh and so on. Also, I tried window.innerHeight suggested in the other post,

I tried

function setRealHeight() {
  const realHeight = document.documentElement.clientHeight;
  document.documentElement.style.setProperty('--real-vh', `${realHeight}px`);
}

window.addEventListener('resize', setRealHeight);
setRealHeight();
+ 
body {
  height: var(--real-vh);
}

and const vh = window.visualViewport.height * 0.01;

But nothing helped.

The only band-aid solution I have "invented" - is to increase bottom padding and to hide the overflow - yet I do not feel it is a good solution.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745168428a4614775.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信