Mobile开发之meta篇
- <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 name="apple-mobile-web-app-status-bar-style" content="black" />
?當設置了app形式之后,作用是控制狀態欄顯示樣式,但是本機ios7測試之后沒啥改變……不解
- <meta name="format-detection"content="telephone=no, email=no" />
iphone會把一串數字識別為電話號碼,點擊的時候會提示是否呼叫,屏蔽這功能則把telephone設置為no,
要啟用電話功能,請使用<a href="tel:13888888888">Call Me : 13888888888</a>來代替,
郵件則為<a href="mailto:someone@microsoft.com?subject=Hello%20again">發送郵件</a>
- 其他的meta設置
此外,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" />所以,對于移動端,把通用的起始模板寫成sublime的snippet:
<snippet><content><![CDATA[ <!DOCTYPE html> <html lang="en"> <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>${1}</title> </head> <body>${2} </body> </html> ]]></content><tabTrigger>mhd</tabTrigger><description>Mobile Frame</description><scope>text.html</scope> </snippet>參考:
http://www.w3cplus.com/mobile/mobile-terminal-refactoring-create-page.html
http://blog.sina.com.cn/s/blog_6d48e77101015kqr.html
http://blog.sina.com.cn/s/blog_3f1fc8950101fz2v.html
總結
以上是生活随笔為你收集整理的Mobile开发之meta篇的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jetbrains goland配置go
- 下一篇: Java 移位运算详解