移动端web页面开发常用的头部标签设置
source link: https://blog.p2hp.com/archives/10759
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
在移动端web页面开发中,我们常需要设置各种头部标签以帮助浏览器更好的解析页面,将页面完美呈现,这里列出了工作中常用的各种头部标签,以备查询。
viewport
<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可以使用以下方法
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
<meta name="apple-mobile-web-app-capable" content="yes"/>
启用 WebApp 全屏模式,删除苹果默认的工具栏和菜单栏
<meta name="apple-mobile-web-app-title" content="标题">
设置添加到主屏后的标题
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
在web app应用下状态条(屏幕顶部条)的颜色,default(白色)black(黑色) black-translucent(灰色半透明)
若值为"black-translucent"将会占据页面位置(会覆盖页面20px高度–iphone4和itouch4的Retina屏幕为40px)。
<meta name="format-detection" content="telphone=no, email=no"/>
忽略页面中的数字识别为电话,忽略email识别
iOS 添加到主屏图标
<link rel="apple-touch-icon" href="apple-touch-icon.png">
ios7以前系统默认会对图标添加特效(圆角及高光),如果不希望系统添加特效,则可以用apple-touch-icon-precomposed.png代替apple-touch-icon.png
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-57x57-precomposed.png"/>
iPhone 和 iTouch,默认 57x57 像素,必须有
<link rel="apple-touch-icon-precomposed" href="apple-touch-icon-114x114-precomposed.png"/>
Retina iPhone 和 Retina iTouch,114x114 像素,可以没有,但推荐有
图标使用的优先级如下:
- 如果没有跟相应设备推荐尺寸一致的图标,会优先使用比推荐尺寸大,但最接近推荐尺寸的图标。
- 如果没有比推荐尺寸大的图标,会优先选择最接近推荐尺寸的图标。
iOS 启动画面
iPhone
<link rel="apple-touch-startup-image" media="(device-width: 320px)" href="apple-touch-startup-image-320x460.png" />
iPhone Retina
<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
<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
<link href="apple-touch-startup-image-768x1004.png" media="(device-width: 768px) and (orientation: portrait)" rel="apple-touch-startup-image" />
iPad landscape
<link href="apple-touch-startup-image-748x1024.png" media="(device-width: 768px) and (orientation: landscape)" rel="apple-touch-startup-image" />
iPad Retina portrait
<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
<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" />
<link rel="dns-prefetch" href="//api.m.taobao.com">
DNS预解析
<link rel="shortcut icon" type="image/ico" href="/favicon.ico"/>
添加 favicon icon
<meta name="renderer" content="webkit">
启用360浏览器的极速模式(webkit)
<meta http-equiv="X-UA-Compatible" content="IE=edge">
IE使用现有最高版本
<meta http-equiv="Cache-Control" content="no-siteapp" />
不让百度转码
<meta name="x5-orientation" content="portrait">
QQ强制竖屏
<meta name="x5-fullscreen" content="true">
QQ强制全屏
<meta name="x5-page-mode" content="app">
QQ应用模式
<meta name="screen-orientation" content="portrait">
UC强制竖屏
<meta name="full-screen" content="yes">
UC强制全屏
<meta name="browsermode" content="application">
UC应用模式
<meta name="msapplication-tap-highlight" content="no">
windows phone 点击无高光
<meta name="robots" content="index,follow"/>
搜索引擎抓取
说明:
robots用来告诉搜索机器人哪些页面需要索引,哪些页面不需要索引。
具体参数如下:
信息参数为all:文件将被检索,且页面上的链接可以被查询;
信息参数为none:文件将不被检索,且页面上的链接不可以被查询;
信息参数为index:文件将被检索;
信息参数为follow:页面上的链接可以被查询;
信息参数为noindex:文件将不被检索,但页面上的链接可以被查询;
信息参数为nofollow:文件将被检索,但页面上的链接不可以被查询;
HTML meta标签总结,HTML5 head meta属性整理
Safari Web Content Guide
Safari HTML Reference
Recommend
-
51
前言 在平时的H5移动端开发时,我们难免会遇到各种各样的坑点,这篇文章就带着大家来看看怎么解决,文章较长,建议收藏方便以后查阅!
-
11
1:@RequestParam作用:吧请求中指定名称的参数给控制器中的形参赋值属性:required:请求参数中是否必须提供此参数。默认值:true,表示必须提供条件,否则报错,改为false,不会报错当没有接到值不会报错,会显示null2:@RequestBody作用:用于获取请求体内容。直接...
-
44
前言 年后第一天到公司上班,整理一些在移动端H5开发常见的问题给大家做下分享,这里很多是自己在开发过程中遇到的大坑或者遭到过吐糟的问题,希望能给大家带来或多或少的帮助,喜欢的大佬们可以给个小赞,如果有问题也可以一起讨论下。 下面是最近一个月整理的JS...
-
8
因为Wordpress模板基本都需要调用到wp_head()这个函数,而这个函数自带了很多网页用不上的标签和链接资源。当网站打开的时候,这些相关调用都会影响到网站加载速度,而且这代码沉余会严重影响到SEO的整体优化,所以还是有必要清理干净。只要把下面的清除代码放...
-
5
欧雷说:「问个问题——会有那种在一个网页中通过多个选项卡标签的形式打开多个“页面”的后台系统,可以认为是在网页...」 欧雷 发表于 2021-07-16 21:44 问个问题——
-
3
V2EX › Android 一个 webview 中包 video 标签的问题,在一个页面中 上下都有间隔 全屏播放正常的会铺满上下间隔之间;
-
4
如何创建非方形的页面头部 | Lenix BlogOver at Medium, Jon Moore recently identified “non-rectangular headers” as a tiny trend. A la: it’s not cr...
-
6
工业移动机器人头部厂商「优艾智合」,为何要给产品“买保险”?刘晓潼@36氪广东·2022-09-28 09:42移动机器人工业领域规模化落地的当下,保险业与移动机器人...
-
2
新浪VR > 正文页 Valve 在 Steam 商店页面添加“VR 支持”和“VR 独占”功能标签...
-
6
既然浏览器中可以使用页面标签,那为什么在项目中还需要使用这个组件和交互框架的形式呢?本文IE等浏览器界面为例,介绍了页面标签在产品设计中的作用,以及它们在不同使用场景当中的效果。希望能帮助你对页面标签形成新的认识,推荐关注产品设计的小伙...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK