如何在HTML中动态使用javascript设置屏幕分辨率?

dip*_*dip -7 mobile

我正在为移动和iPod开发一个网络应用程序,因此与平台无关.为此,我使用html作为嵌入在adv.java servlet中的前端.

但是,我的屏幕分辨率存在很大问题.如何为任何Web浏览器动态设置屏幕分辨率?

理想情况下我不想要水平滚动条; 那么什么方法可能在这里工作?

Gre*_*g B 5

使用css3媒体查询更改页面设计:

http://www.webdesignerwall.com/tutorials/css3-media-queries/

适用于iPhone 4

以下样式表专门针对iPhone 4(演职员:Thomas Maier).

<link rel="stylesheet" media="only screen and (-webkit-min-device-pixel-ratio: 2)" type="text/css" href="iphone4.css" />
Run Code Online (Sandbox Code Playgroud)

适用于iPad

您还可以使用媒体查询来检测iPad上的方向(纵向或景观)(信用:Cloud Four).

<link rel="stylesheet" media="all and (orientation:portrait)" href="portrait.css">
<link rel="stylesheet" media="all and (orientation:landscape)" href="landscape.css">
Run Code Online (Sandbox Code Playgroud)