我正在设计一个移动网站,我首先尝试使用带有 h1 标签的常规 html 页面。它看起来很小,所以我搜索并发现我需要添加这些行:
<meta name="viewport" content="width=device-width" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=yes" />
试了几个网页看懂了,还是一头雾水。视口(viewport)是否是额外的设备宽度,例如 iPhone 上的宽度为 960px?即使 iPhone 4 只有 640px,所以它缩小它来模拟那个尺寸?所以为了防止它认为视口(viewport)是 960px,它说它等于屏幕大小?
如果是这种情况,其他浏览器/设备(例如 Android 运行设备)是否具有不同的宽度(960px 除外)?
最佳答案
根据 jquery 移动文档,iOS 有一个错误:
There is a minor issue in iOS that doesn't properly set the width when changing orientations with these viewport settings, but this will hopefully be fixed a a future release. You can set other viewport values to disable zooming if required since this is part of your page content, not the library.
他们推荐以下行:
<meta name="viewport" content="width=device-width, initial-scale=1">
您也不需要用户可缩放,上面的行不会禁用用户缩放。
关于html - 视口(viewport)元标记的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9189491/