html5移动网页自适应手机屏幕的meta写法

@一棵菜菜  July 30, 2018

1、移动网站要加的html5相关meta和标签
a、强制让文档与设备的宽度保持1:1

 <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">

网页宽度默认等于屏幕宽度(width=device-width),
初始缩放比例(initial-scale=1)为1.0,即网页初始大小占屏幕面积的100%。

b、删除默认的苹果工具栏和菜单栏

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

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

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

d、禁止了把数字转化为拨号链接

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

e、浏览网站时的小图标

<link rel="shortcut icon" href="http://p.www.xiaomi.com/favicon.ico" type="/image/x-icon">  

f、添加至主屏时的图片

<link rel="apple-touch-icon-precomposed" href="http://a.tbcdn.cn/mw/s/hi/tbtouch/images/touch-icon.png">
==================
还有一种有趣的方法
创建html5时发现这么一句话,如下:
<meta http-equiv=”X-UA-Compatible” content=”IE=edge,chrome=1″/>


这样写可以达到的效果是如果安装了GCF(Google Chrome Frame 谷歌内嵌浏览器框架的简称),则使用GCF来渲染页面,如果没安装GCF,则使用最高版本的IE内核进行渲染。这个插件可以让用户的IE浏览器外不变,但用户在浏览网页时,实际上使用的是Google Chrome浏览器内核,而且支持IE6、7、8等多个版本的IE浏览器。
原文地址:https://blog.csdn.net/katanaFlower/article/details/78620604

添加新评论