html - 视口(viewport)元标记的用途是什么?

标签 html mobile

我正在设计一个移动网站,我首先尝试使用带有 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/

相关文章:

javascript - 如何在html onclick中调用类函数

html - 将两个方 block 排成一行,避免它们相互重叠

javascript - jquery 中未选择第二个 div 元素

android - 如果用户向下/向上滑动,不要关闭 Photoswipe

android - 不同移动平台的文件格式是什么

javascript - 如何制作长度统一的列表项?

javascript - onload函数内的函数未定义?

android - Flex 移动应用程序不适用于 android 2.2

android - 具有附加下拉菜单的 Material 设计TextInputLayout?

jquery - 提交 JQuery 移动表单而不重定向到 php 文件