HTML5常用<meta>屏幕适配标签设置

适应手机端

<meta name="viewport" content="width-device-width,initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0,user-scalable=no, minimal-ui">

width - viewport的宽度 height - viewport的高度

initial-scale - 初始的缩放比例

minimum-scale - 允许用户缩放到的最小比例

maximum-scale - 允许用户缩放到的最大比例

user-scalable - 用户是否可以手动缩放



下面是我们经常用到的一些标签,由于浏览器的差异,并不能百分百兼容

<!--是否删除默认的苹果工具栏和菜单栏-->

<meta name="apple-mobile-web-app-capable" content="yes"/>

<!--避免IE使用兼容模式-->

<meta http-equiv="X-UA-Compatible" content="IE=edge"/>

<!--针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑莓-->

<meta name="HandheldFriendly" content="true"/>

<!--微软的老式浏览器-->

<meta name="MobileOptimized" content="320"/>

<!--uc强制竖屏-->

<meta name="screen-orientation" content="portrait"/>

<!--QQ强制竖屏-->

<meta name="x5-orientation" content="portrait"/>

<!--UC强制全屏-->

<meta name="full-screen" content="yes"/>

<!--QQ强制全屏-->

<meta name="x5-fullscreen" content="true"/>

<!--UC应用模式-->

<meta name="browsermode" content="application"/>

<!--QQ应用模式-->

<meta name="x5-page-mode" content="app"/>

<!--windows phone 点击无高光-->

<meta name="msapplication-tap-highlight" content="no"/>

在iPhone 手机上默认值是(电话号码显示为拨号的超链接):

<meta name="format-detection" content="telephone=yes"/>

可将telephone=no,则手机号码不被显示为拨号链接

<meta name="format-detection" content="telephone=no"/>

apple-touch-icon:

<link rel="apple-touch-icon" sizes="76x76" href="touch-icon-ipad.png"/>

如果 apple-mobile-web-app-capable 设置为 yes 了,那么在苹果机的safari上可以通过添加到主屏按钮将网站添加到主屏幕上。而设置相应 apple-touch-icon 标签,则添加到主屏上的图标就会使用我们指定的图片。

apple-touch-startup-image:

<link rel="apple-touch-startup-image" href="/startup.png"/>

基于 apple-mobile-web-app-capable 设置为 yes ,可以为WebApp设置一个类似NativeApp的启动画面。和 apple-touch-icon 不同, apple-mobile-web-app-capable 不支持sizes属性,要使用media来加载不同的启动画面。

网站开启对web app程序的支持

<meta name="apple-mobile-web-app-status-bar-style" content="black"/>

- 在web app应用下状态条(屏幕顶部条)的颜色

- 默认值为default(白色),可以定为black(黑色)和black-translucent(灰色半透明)。

- 若值为“black-translucent”将会占据页面px位置,浮在页面上方(会覆盖页面20px高度–iphone4和itouch4的Retina屏幕为40px)。

参考:

http://www.w3cplus.com/mobile/mobile-terminal-refactoring-create-page.html

http://blog.sina.com.cn/s/blog_6d48e77101015kqr.html

http://blog.sina.com.cn/s/blog_3f1fc8950101fz2v.html

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容