标签:
基本在网页头部我们只需添加四个meta标签就可以实现一个手机网站的框架。我一起来看看是哪些meta标签。
1、添加viewport标签
|
1
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /> |
详细属性:
|
1
2
3
4
5
6
|
width ---- viewport的宽度(width=device-width意思是:宽度等于设备宽度)height ------ viewport的高度(height=device-height意思是:高度等于设备宽度)initial-scale ----- 初始的缩放比例minimum-scale ----- 允许用户缩放到的最小比例maximum-scale ----- 允许用户缩放到的最大比例user-scalable ----- 用户是否可以手动缩放 |
关于viewport的详细原理和知识点,各位就百度吧!在这里我就不做详细的讲解了。
2、禁止将数字变为电话号码
|
1
|
<meta name="format-detection" content="telephone=no" /> |
一般情况下,IOS和Android系统都会默认某长度内的数字为电话号码,即使不加也是会默认显示为电话的,so,取消这个很有必要!
3、iphone设备中的safari私有meta标签
|
1
|
<meta name="apple-mobile-web-app-capable" content="yes" /> |
它表示:允许全屏模式浏览,隐藏浏览器导航栏
4、iphone的私有标签
|
1
|
<meta name="apple-mobile-web-app-status-bar-style" content="black"> |
它指定的iphone中safari顶端的状态条的样式
默认值为default(白色),可以定为black(黑色)和black-translucent(灰色半透明)
另外还有一个个性化的link标签,它支持用户将网页创建快捷方式到桌面时,其图标变为我们自己定义的图标。比如手机腾讯网上的标签:
|
1
|
<link rel="apple-touch-icon-precomposed" href="http://3gimg.qq.com/wap30/info/info5/img/logo_icon.png"> |
不过腾讯对这个png图标的命名并不规范,常规我们要求文件名应为 apple-touch-icon.png 或 apple-touch-icon-precomposed.png ,前者的命名iOS会为这个图标自动添加圆角、阴影和高亮覆盖层,后者则不会添加这些效果。
手机网站基本框架代码:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<!doctype html><html><head><meta charset="utf-8"><title>手机网站</title><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"><meta name="author" content="duanliang, duanliang920.com" /><style> body{font-size:62.5%;font-family:"Microsoft YaHei",Arial; overflow-x:hidden; overflow-y:auto;} .viewport{ max-width:640px; min-width:300px; margin:0 auto;}</style> </head><body> <div> 大家好!这是我的第一个手机网页哦! </div></body></html> |
标签:
原文地址:http://www.cnblogs.com/manxin/p/5536780.html