如何在iPhone Web应用程序中将方向锁定为纵向模式? [英] How do I lock the orientation to portrait mode in a iPhone Web Application?

查看:91
本文介绍了如何在iPhone Web应用程序中将方向锁定为纵向模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个iPhone Web应用程序,并希望将方向锁定为纵向模式。这可能吗?是否有任何网络工具包扩展来执行此操作?

I'm building a iPhone Web Application and want to lock the orientation to portrait mode. is this possible? Are there any web-kit extensions to do this?

请注意这是一个用HTML和JavaScript编写的适用于Mobile Safari的应用程序,它不是用Objective编写的本机应用程序-C。

Please note this is an application written in HTML and JavaScript for Mobile Safari, it is NOT a native application written in Objective-C.

推荐答案

您可以根据视口方向指定CSS样式:
使用body定位浏览器[orient =landscape ]或身体[orient =portrait]

You can specify CSS styles based on viewport orientation: Target the browser with body[orient="landscape"] or body[orient="portrait"]

http://www.evotech.net/blog/2007/07/web-development-for-the-iphone/

然而......

Apple解决此问题的方法是允许开发人员根据方向更改来更改CSS但不是为了防止完全重新定位。我在其他地方发现了类似的问题:

Apple's approach to this issue is to allow the developer to change the CSS based on the orientation change but not to prevent re-orientation completely. I found a similar question elsewhere:

http://ask.metafilter.com/99784/How-can-I-lock-iPhone-orientation-in-Mobile-Safari

这篇关于如何在iPhone Web应用程序中将方向锁定为纵向模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆