[HTML5]移动端web页面开发常用的头部标签设置

[HTML5]移动端web页面开发常用的头部标签设置

移动端web页面开发常用的头部标签设置

在移动端web页面开发中,我们常需要设置各种头部标签以帮助浏览器更好的解析页面,将页面完美呈现,这里列出了工作中常用的各种头部标签,以备查询。

viewport

html 复制代码
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">

initial-scale属性控制页面最初加载时的缩放等级。maximum-scale、minimum-scale及user-scalable属性控制允许用户以怎样的方式放大或缩小页面。
使用目的:阻止页面缩放
Safari 无效,其他均能阻止页面缩放
safari可以使用以下方法

html 复制代码
window.onload = function() {
  document.addEventListener('touchstart', function(event) {
    if (event.touches.length > 1) {//多触点
      event.preventDefault();//阻止默认缩放
    }
  })
  var lastTouchEnd = 0;
  document.addEventListener('touchend', function(event) {
    var now = (new Date()).getTime();
    if (now - lastTouchEnd <= 300) {
      event.preventDefault(); //阻止双击放大
    }
    lastTouchEnd = now;
  }, false)
}

ios meta

html 复制代码
<meta name="apple-mobile-web-app-capable" content="yes"/>

启用 WebApp 全屏模式,删除苹果默认的工具栏和菜单栏

html 复制代码
<meta name="apple-mobile-web-app-title" content="标题">

设置添加到主屏后的标题

html 复制代码
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>

在web app应用下状态条(屏幕顶部条)的颜色,default(白色)black(黑色) black-translucent(灰色半透明)

若值为"black-translucent"将会占据页面位置(会覆盖页面20px高度--iphone4和itouch4的Retina屏幕为40px)。

html 复制代码
<meta name="format-detection" content="telphone=no, email=no"/>

忽略页面中的数字识别为电话,忽略email识别

iOS 添加到主屏图标

html 复制代码
<link rel="apple-touch-icon" href="apple-touch-icon.png">

ios7以前系统默认会对图标添加特效(圆角及高光),如果不希望系统添加特效,则可以用apple-touch-icon-precomposed.png代替apple-touch-icon.png

html 复制代码
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-57x57-precomposed.png"/>

iPhone 和 iTouch,默认 57x57 像素,必须有

html 复制代码
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-114x114-precomposed.png"/>

Retina iPhone 和 Retina iTouch,114x114 像素,可以没有,但推荐有
图标使用的优先级如下:

  • 如果没有跟相应设备推荐尺寸一致的图标,会优先使用比推荐尺寸大,但最接近推荐尺寸的图标。
  • 如果没有比推荐尺寸大的图标,会优先选择最接近推荐尺寸的图标。

iOS 启动画面
iPhone

html 复制代码
<link rel="apple-touch-startup-image" media="(device-width: 320px)" href="apple-touch-startup-image-320x460.png"   /> 

iPhone Retina

html 复制代码
<link href="apple-touch-startup-image-640x920.png" media="(device-width: 320px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image" /> 

iPhone 5

html 复制代码
<link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)" href="apple-touch-startup-image-640x1096.png"> 

iPad portrait

html 复制代码
<link href="apple-touch-startup-image-768x1004.png" media="(device-width: 768px) and (orientation: portrait)" rel="apple-touch-startup-image" /> 

iPad landscape

html 复制代码
<link href="apple-touch-startup-image-748x1024.png" media="(device-width: 768px) and (orientation: landscape)" rel="apple-touch-startup-image" /> 

iPad Retina portrait

html 复制代码
<link href="apple-touch-startup-image-1536x2008.png" media="(device-width: 1536px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image" /> 

iPad Retina landscape

html 复制代码
<link href="apple-touch-startup-image-1496x2048.png"media="(device-width: 1536px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 2)"rel="apple-touch-startup-image" />

其他

html 复制代码
<link rel="dns-prefetch" href="//api.m.taobao.com">

DNS预解析

html 复制代码
<link rel="shortcut icon" type="image/ico" href="/favicon.ico"/>

添加 favicon icon

html 复制代码
<meta name="renderer" content="webkit">

启用360浏览器的极速模式(webkit)

html 复制代码
<meta http-equiv="X-UA-Compatible" content="IE=edge">

IE使用现有最高版本

html 复制代码
<meta http-equiv="Cache-Control" content="no-siteapp" />

不让百度转码

html 复制代码
<meta name="x5-orientation" content="portrait">

QQ强制竖屏

html 复制代码
<meta name="x5-fullscreen" content="true">

QQ强制全屏

html 复制代码
<meta name="x5-page-mode" content="app">

QQ应用模式

html 复制代码
<meta name="screen-orientation" content="portrait">

UC强制竖屏

html 复制代码
<meta name="full-screen" content="yes">

UC强制全屏

html 复制代码
<meta name="browsermode" content="application">

UC应用模式

html 复制代码
<meta name="msapplication-tap-highlight" content="no">

windows phone 点击无高光

html 复制代码
<meta name="robots" content="index,follow"/>

搜索引擎抓取

说明:

robots用来告诉搜索机器人哪些页面需要索引,哪些页面不需要索引。

具体参数如下:

信息参数为all:文件将被检索,且页面上的链接可以被查询;

信息参数为none:文件将不被检索,且页面上的链接不可以被查询;

信息参数为index:文件将被检索;

信息参数为follow:页面上的链接可以被查询;

信息参数为noindex:文件将不被检索,但页面上的链接可以被查询;

信息参数为nofollow:文件将被检索,但页面上的链接不可以被查询;

相关推荐
昱禹4 分钟前
关于CSS Grid布局
前端·javascript·css
啊QQQQQ11 分钟前
HTML:相关概念以及标签
前端·html
就叫飞六吧1 小时前
vue2和vue3全面对比
前端·javascript·vue.js
Justinc.1 小时前
CSS基础-盒子模型(三)
前端·css
qq_2518364571 小时前
基于ssm vue uniapp实现的爱心小屋公益机构智慧管理系统
前端·vue.js·uni-app
._Ha!n.1 小时前
Vue基础(二)
前端·javascript·vue.js
风清扬_jd2 小时前
Chromium 硬件加速开关c++
java·前端·c++
谢尔登3 小时前
【React】事件机制
前端·javascript·react.js
2401_857622664 小时前
SpringBoot精华:打造高效美容院管理系统
java·前端·spring boot
etsuyou4 小时前
Koa学习
服务器·前端·学习