Viewport meta tag for iOS devices

我的梦境 提交于 2019-11-27 17:24:30

问题


Does stating

<meta name="viewport" content="width=device-width" />

have the same effect as stating

<meta name="viewport" content="width=768" />

for the ipad?


回答1:


It depends indeed on the orientation of the device: setting a specific pixel value will cause your layout to be scaled up with a factor of 1.333 to fit inside the 1024px device width when in landscape mode.

Setting width=device-width on the other hand will not scale anything up, but change the viewport width, for which you then can craft an optimized layout using media queries. Or that is at least the theory: the iPad somehow interprets width=device-width as 768px even in landscape mode. In order to get the real device width, you have to add initial-scale=1.

Hence, I disagree with James' suggestion. Just go for:

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

and deal with size differences using liquid / responsive layout techniques.



来源:https://stackoverflow.com/questions/7892809/viewport-meta-tag-for-ios-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!