1. 程式人生 > >HTML的meta標簽

HTML的meta標簽

圖片 safari media keyword 通過 cnblogs friend end native

<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, minimal-ui" /> 

width: viewport 的寬度 (範圍從 200 到 10,000 ,默認為 980 像素 )

height: viewport 的高度 (範圍從 223 到 10,000 )

initial-scale: 初始的縮放比例 (範圍從>0到 10 )

minimum-scale: 允許用戶縮放到的最小比例

maximum-scale: 允許用戶縮放到的最大比例

user-scalable: 用戶是否可以手動縮放

下面是我們經常用到的一些標簽,由於瀏覽器的差異,並不能百分百兼容。

<!-- 是否刪除默認的蘋果工具欄和菜單欄 -->
<meta name="apple-mobile-web-app-capable" content="yes" />

<!-- 其他的meta設置 -->
<!-- 啟用360瀏覽器的極速模式(webkit) -->
<meta name="renderer" content="webkit">

<!-- 避免IE使用兼容模式 -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<!-- 針對手持設備優化,主要是針對一些老的不識別viewport的瀏覽器,比如黑莓 -->
<meta name="HandheldFriendly" content="true">

<!-- 微軟的老式瀏覽器 -->
<meta name="MobileOptimized" content="320">

<!-- uc強制豎屏 -->
<meta name="screen-orientation" content="portrait">

<!-- QQ強制豎屏 -->
<meta name="x5-orientation" content="portrait">

<!-- UC強制全屏 -->
<meta name="full-screen" content="yes">

<!-- QQ強制全屏 -->
<meta name="x5-fullscreen" content="true">

<!-- UC應用模式 -->
<meta name="browsermode" content="application">

<!-- QQ應用模式 -->
<meta name="x5-page-mode" content="app">

<!-- windows phone 點擊無高光 -->
<meta name="msapplication-tap-highlight" content="no">

此外,apple還有兩個有趣的標簽:

1. apple-touch-icon

< link  rel= "apple-touch-icon"  sizes= "76x76"  href= "touch-icon-ipad.png">

如果 apple-mobile-web-app-capable 設置為 yes 了,那麽在蘋果機的safari上可以通過添加到主屏按鈕將網站添加到主屏幕上。而設置相應 apple-touch-icon 標簽,則添加到主屏上的圖標就會使用我們指定的圖片。

2. apple-touch-startup-image

< link rel= "apple-touch-startup-image" href= "/startup.png">

基於 apple-mobile-web-app-capable 設置為 yes ,可以為WebApp設置一個類似NativeApp的啟動畫面。和 apple-touch-icon 不同, apple-mobile-web-app-capable 不支持sizes屬性,要使用media來加載不同的啟動畫面。詳細查詢 大漠的文章 。

// iPhone
<link href="apple-touch-startup-image-320x460.png" media="(device-width: 320px)" rel="apple-touch-startup-image" />
// 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 手機上默認值是(電話號碼顯示為撥號的超鏈接):

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

可將telephone=no,則手機號碼不被顯示為撥號鏈接

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



更詳細的內容:http://www.cnblogs.com/yuzhongwusan/archive/2011/11/29/2267568.html

官方文檔:https://developer.apple.com/library/safari/documentation/appleapplications/reference/SafariHTMLRef/Articles/MetaTags.html

http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications

 

HTML的meta標簽