文章出處

 

以前看書的時候,覺得meta標簽就只有一個charset對于我來說是有用的。前段時間有個學弟讓我寫個手機版的網頁,我才知道原來meta標簽有那么多學問。

meta指元素可提供有關頁面的元信息(meta-information),比如針對搜索引擎和更新頻度的描述和關鍵詞。 標簽位于文檔的頭部,不包含任何內容。 標簽的屬性定義了與文檔相關聯的名稱/值對。

meta標簽的作用有:搜索引擎優化(SEO),定義頁面使用語言,自動刷新并指向新的頁面,實現網頁轉換時的動態效果,控制頁面緩沖,網頁定級評價,控制網頁顯示的窗口等

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

強制讓文檔的寬度與設備的寬度保持1:1,并且文檔最大的寬度比例是1.0,且不允許用戶點擊屏幕放大瀏覽;

width - viewport的寬度 height - viewport的高度    initial-scale - 初始的縮放比例   minimum-scale - 允許用戶縮放到的最小比例    maximum-scale - 允許用戶縮放到的最大比例   user-scalable - 用戶是否可以手動縮放

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

是iphone設備中的safari私有meta標簽,它表示:允許全屏模式瀏覽;
第三個meta標簽也是iphone的私有標簽,它指定的iphone中safari頂端的狀態條的樣式;

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

在web app應用下狀態條(屏幕頂部條)的顏色;默認值為default(白色),可以定為black(黑色)和black-translucent(灰色半透明)。注意:若值為“black-translucent”將會占據頁面px位置,浮在頁面上方(會覆蓋頁面20px高度–iphone4和itouch4的Retina屏幕為40px)。

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

告訴設備忽略將頁面中的數字識別為電話號碼。

{下面是在寫App時常常會用到的一些meta總結:}

 1 #手機頁面重要meta
 2 
 3 > 設置寬度為設備的寬度,默認不縮放,不允許用戶縮放(即禁止縮放),在網頁加載時隱藏地址欄與導航欄
 4     <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, minimal-ui" />
 5 
 6 > 禁止識別手機號碼
 7     <meta name="format-detection" content="telephone=no" />
 8 
 9 > 關閉識別手機號碼后若要識別某一個手機號
10     <a href="tel:13800138000">13800138000</a>
11 
12 > 禁止識別郵箱
13     <meta content="email=no" name="format-detection" />
14 
15 > 是否啟動webapp功能,會刪除默認的蘋果工具欄和菜單欄。
16     <meta name="apple-mobile-web-app-capable" content="yes" />
17 
18 > 當啟動webapp功能時,顯示手機信號、時間、電池的頂部導航欄的顏色。默認值為default(白色),可以定為black(黑色)和black-translucent(灰色半透明)。
19     <meta name="apple-mobile-web-app-status-bar-style" content="black" />
20 
21 > 用戶把網頁存為書簽時,在手機HOME界面創建應用程序樣式的圖標。
22     <link rel="apple-touch-icon" href="/static/images/identity/HTML5_Badge_64.png" />
23     <link rel="apple-touch-icon-precomposed" href="/static/images/identity/HTML5_Badge_64.png" />
24 
25 > webapp添加啟動動畫
26     <link rel="apple-touch-startup-image" href="startup.png" />
27 
28 > 其他模式
29     <!-- uc強制豎屏 -->
30     <meta name="screen-orientation" content="portrait">
31     <!-- QQ強制豎屏 -->
32     <meta name="x5-orientation" content="portrait">
33     <!-- UC強制全屏 -->
34     <meta name="full-screen" content="yes">
35     <!-- QQ強制全屏 -->
36     <meta name="x5-fullscreen" content="true">
37     <!-- UC應用模式 -->
38     <meta name="browsermode" content="application">
39     <!-- QQ應用模式 -->
40     <meta name="x5-page-mode" content="app">
41     <!-- 360 Webkit -->
42     <meta name="renderer" content="webkit">

還有五個大型網站手機觸屏版的頁面使用meta的實例,我們在剛開始接觸的時候可以借鑒和學習。

一、天貓

<title>天貓觸屏版</title>

<meta content="text/html; charset=utf-8" http-equiv="Content-Type">

<meta charset="utf-8">

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

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

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

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

二、淘寶

<title>淘寶網觸屏版</title>

<meta charset="utf-8">

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

<meta content="yes" name="apple-touch-fullscreen">

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

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

<meta property="wb:webmaster" content="c51923015ca19eb1">

<meta name="author" content="m.taobao.com">

<meta name="copyright" content="Copyright ©m.taobao.com 版權所有">

<meta name="revisit-after" content="1 days">

<meta name="keywords" content="">

<meta name="description" content="">

三、京東

<title> 京東 - 手機版 </title>

<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="Keywords" content="手機購物,WAP商城,日用百貨,3C家電,汽車用品">

<meta name="description" content="京東手機版提供了包括數碼、家電、手機、電腦配件、網絡產品、日用百貨等數萬種商品,手機快捷購物,就上京東手機版。">

四、網易

<title>手機網易網</title>

<meta charset="UTF-8">

<meta content="width=device-width,user-scalable=no" name="viewport">

<meta name="apple-itunes-app" content="app-id=425349261">

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

五、百度

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

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

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

 


文章列表


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()