Android浏览器:填充垂直视口?
我有一个网络应用程序,我想完全垂直地填充浏览器视口,包括将地址栏推到顶部。
有没有办法在没有地址栏的情况下获取浏览器视口大小?目前,我正在使用 jQuery,例如:
$("#mainBox").height($(window).height)
但这将填充视口减去地址栏,导致在横向查看时元素太窄。
对于 iPhone,我通过将 iPhone 浏览器视口大小硬编码到页面中来解决这个问题,但这样做存在明显的问题。
I have a web app that I want to exactly vertically fill the browser viewport, including pushing the address bar up past the top.
Is there some way of getting the browser viewport size without the address bar? Currently, I am using jQuery like:
$("#mainBox").height($(window).height)
but this will fill the viewport minus the address bar, causing the element to be too narrow when viewed in landscape.
For iPhone, I was getting around this by hard-coding the iPhone browser viewport sizes into the page, but there are obvious problems with that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在 oerintationchange 事件中重置高度。那么,如果您为窗口创建一个orientationchange事件处理程序,您需要在该处理程序内调用同一行,您将获得新的窗口高度,您应该很好。
You need to reset the height in an oerintationchange event. So is you create an orientationchange event handler for the window you need to call the same line inside that handler and you will get the new window height and you should be good.