【问题标题】:Is there a way to control window height on mobile with CSS or jQuery?有没有办法使用 CSS 或 jQuery 控制移动设备上的窗口高度?
【发布时间】:2021-05-02 05:56:41
【问题描述】:

我在移动浏览器的窗口高度方面遇到了一些问题。 我正在使用 css 100vw,但它并不总是准确的 - 特别是当浏览器显示附加功能时 - 我的意思是顶部的导航栏或底部的功能按钮。

简单来说 - 他们去掉了窗口的大小,但它并不是指精确计算的窗口大小。

我放视频是为了更好地说明我在说什么: As you can see here - where i'm opening chat window the window height is changing during keyboard show-up - but window itself does not change the size - when i enter it second time - the window height is changing - how i can get controll over it?

Here when the bottom stripe is added the height of the chat window is ok - it's computed by CSS height:calc(100vh - px) and it's work But when stripe is gone - window height remain the same - so the height is much lower

如何通过此窗口的附加功能获取移动窗口的高度? (添加地址栏、功能按钮或键盘?)。

(电影来自 iPhone iOS - 在 Android 上似乎一切正常)

【问题讨论】:

  • 你的意思是拉/拉手机的长度?开玩笑。是否可以使用百分比,例如“100%”?
  • @GenoChen 问题是 - 打开的窗口在容器内 - 如果我使用“100%”,我会得到容器的高度 - 而不是窗口本身。

标签: html jquery css ios mobile


【解决方案1】:

不要使用100vw,而是尝试使用100%。像这样:

height:100%

【讨论】:

  • 感谢您的回答-但问题是我要设置样式的元素位于容器内-因此,如果我将其设置为 100%,它将得到容器的高度-而不是窗口本身.
  • 好的,我刚刚从容器中取出了这个东西 - 谢谢 - 我希望它可以工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-07-19
  • 2023-04-01
  • 1970-01-01
  • 2013-08-27
  • 2017-08-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多