萬變不離其宗,道法自然!
雖然H5的小項目一波又一波,但有一個東東基本沒什么變化,那就是整個頁面的框架結構。
我所常用的H5常用頁面框架如下:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport"> <meta content="yes" name="apple-mobile-web-app-capable"> <meta content="black" name="apple-mobile-web-app-status-bar-style"> <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"> <meta content="email=no" name="format-detection">
<link rel="stylesheet" href="css/*.css" type="text/css"> <title>主結構</title> </head> <body> 頁面內容頁面內容
<script type="text/javascript" src="js/*.js"></script> </body> </html>
meta設置部分:
viewport設置為屏幕的寬度,禁用縮放
apple-mobile-web-app-capable:當網站添加到主屏幕快速啟動方式,可隱藏地址欄,僅針對ios的safari
apple-mobile-web-app-status-bar-style:將網站添加到主屏幕快速啟動方式,僅針對ios的safari頂端狀態條的樣式
telephone=no:禁用自動識別手機號
email=no:禁用自動識別郵箱
樣式JS引入:
head部分link方式引入樣式
body尾部引入JS
以上代碼歸屬於我的github常用H5代碼整理項目(詳見其中template):https://github.com/xw5/mobile-code/
歡迎clone,歡迎star,一起學習,一起進步