meta name= viewport content= width=device-width, initial-scale=1, user-scalable=no, minimal-ui / meta name= apple-mobile-web-app-capable content= yes / meta name= apple-mobile-web-app-status-bar-style content= black / meta name= format-detection content= telephone=no, email=no /viewport
視圖窗口,移動端特屬的標簽。一般使用下面這段代碼即可:
meta name= viewport content= width=device-width, initial-scale=1, user-scalable=no, minimal-ui /
上面的代碼依次表示設置寬度為設備的寬度,默認不縮放,不允許用戶縮放(即禁止縮放),在網頁加載時隱藏地址欄與導航欄(ios7.1新增)。
width – // [pixel_value | device-width] viewport 的寬度,范圍從 200 到 10,000,默認為 980 像素height – // [pixel_value | device-height ] viewport 的高度,范圍從 223 到 10,000 initial-scale – // float_value,初始的縮放比例 (范圍從 0 到 10)minimum-scale – // float_value,允許用戶縮放到的最小比例maximum-scale – // float_value,允許用戶縮放到的最大比例user-scalable – // [yes | no] 用戶是否可以手動縮放target-densitydpi = [dpi_value | device-dpi | high-dpi | medium-dpi | low-dpi] 目標屏幕像素密度
注:target-densitydpi屏幕像素密度和縮放有關,你可以試試修改這個demo,用手機看下實際效果。我一般不設置這個屬性。
apple-mobile-web-app-capable是否啟動webapp功能,會刪除默認的蘋果工具欄和菜單欄。
meta name= apple-mobile-web-app-capable content= yes /apple-mobile-web-app-status-bar-style
當啟動webapp功能時,顯示手機信號、時間、電池的頂部導航欄的顏色。默認值為default(白色),可以定為black(黑色)和black-translucent(灰色半透明)。這個主要是根據實際的頁面設計的主體色為搭配來進行設置。
meta name= apple-mobile-web-app-status-bar-style content= black /
注:如果對apple-mobile-web-app-capable和apple-mobile-web-app-status-bar-style不太理解,可查閱下面的參考資料第三篇文章,里面有截圖說明。
telephone email忽略頁面中的數字識別為電話號碼
meta name= format-detection content= telephone=no /
同樣還有一個email識別
meta name= format-detection content= email=no /
當然兩者可以寫在一起
meta name= format-detection content= telphone=no, email=no /其他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
參考資料:
Supported Meta Tags section of the Safari HTML Reference
移動前端工作的那些事---前端制作篇之meta標簽篇
移動平臺的meta標簽-----神奇的功效
WebApp之Meta標簽
link標簽apple-touch-icon如果apple-mobile-web-app-capable設置為yes了,那么在iPhone,iPad,iTouch的safari上可以使用添加到主屏按鈕將網站添加到主屏幕上。而通過設置相應apple-touch-icon標簽,則添加到主屏上的圖標就會使用我們指定的圖片。
以下是針對ox不同設備,選擇一個最優icon。默認iphone的大小為60px,ipad為76px,retina屏乘以2倍。
link rel= apple-touch-icon href= touch-icon-iphone.png link rel= apple-touch-icon sizes= 76x76 href= touch-icon-ipad.png link rel= apple-touch-icon sizes= 120x120 href= touch-icon-iphone-retina.png link rel= apple-touch-icon sizes= 152x152 href= touch-icon-ipad-retina.png
ios7以前系統默認會對圖標添加特效(圓角及高光),如果不希望系統添加特效,則可以用apple-touch-icon-precomposed.png代替apple-touch-icon.png
圖標使用的優先級如下:
如果沒有跟相應設備推薦尺寸一致的圖標,那個會優先使用比推薦尺寸大,但最接近推薦尺寸的圖標。
如果沒有比推薦尺寸大的圖標,會優先選擇最接近推薦尺寸的圖標。
如些有多個圖標符合推薦尺寸,會優先選擇包含關鍵字precomposed的圖標。
如果未在區域指定用link標簽指定圖標,會自動搜索網站根目錄下以apple-touch-icon為前綴的png圖標。
注:ios7不再為icon添加特效,ios7以前則默認為icon添加特效,除非icon有關鍵字-precomposed.png為后綴。
參考資料:
Specifying a Webpage Icon for Web Clip
WebApp之 apple-touch-icon
http://taylor.fausak.me/2013/11/01/ios-7-web-apps/
apple-touch-startup-image同樣基于apple-mobile-web-app-capable設置為yes,可以用WebApp設置一個類似NativeApp的啟動畫面。
link rel= apple-touch-startup-image href= /startup.png
和apple-touch-icon不同,apple-mobile-web-app-capable不支持sizes屬性,所以使用media來控制retina和橫豎屏加載不同的啟動畫面。
// 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 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 /總結
空白頁面模板,然后再根據具體情況在此基礎上添加apple-touch-icon和apple-touch-startup-image
!DOCTYPE html html head meta charset= UTF-8 meta name= viewport content= width=device-width, initial-scale=1, user-scalable=no, minimal-ui / meta name= apple-mobile-web-app-capable content= yes / meta name= apple-mobile-web-app-status-bar-style content= black / meta name= format-detection content= telephone=no, email=no / title Document /title /head body /body /html
以上就是html移動端-新建空白頁面meta各個標簽的詳解的詳細內容,html教程
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。
新聞熱點
疑難解答