HTML5手机端网站开发meta设置

前端在进行手机端页面开发时,需要在页面head中完成很多基本设置,确保页面在手机端的显示效果。在开发的过程中,是通过meta标签的设置。

1.viewport标签

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /> 
属性介绍:
width  ----  viewport的宽度(width=device-width意思是:宽度等于设备宽度)  
height ------  viewport的高度(height=device-height意思是:高度等于设备宽度)  
initial-scale ----- 初始的缩放比例  
minimum-scale ----- 允许用户缩放到的最小比例  
maximum-scale ----- 允许用户缩放到的最大比例  
user-scalable ----- 用户是否可以手动缩放  

2.禁止将数字变成电话号码,IOS和Android系统都会默认某长度内的数字为电话号码,即使不加也是会默认显示为电话

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

3.iphone设备中的safari私有meta标签,允许全屏模式浏览,隐藏浏览器导航栏

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

4.iphone私有标签

// 指定的iphone中safari顶端的状态条的样式
<meta name="apple-mobile-web-app-status-bar-style" content="black">  
默认值为default(白色),可以定为black(黑色)和black-translucent(灰色半透明)

另外还有一个个性化的link标签,它支持用户将网页创建快捷方式到桌面时,其图标变为我们自己定义的图标。比如手机腾讯网上的标签:

<link rel="apple-touch-icon-precomposed" href="http://3gimg.qq.com/wap30/info/info5/img/logo_icon.png">

汇总一下:

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="keywords" content="" />
  <meta name="description" content="" />
  <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
  <meta name="format-detection" content="telephone=no" />
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <title>web_mobile</title>
</head>

<body>
  <div id="app"></div>
  <!-- built files will be auto injected -->
</body>

</html>
完成以上设置后,就可以较好的进行手机端页面开发。本文结。


猜你喜欢

转载自blog.csdn.net/weixin_37861326/article/details/80105139
今日推荐