手机浏览器会把页面放入到一个虚拟的“视口”(viewpoint)中,但viewport又不局限于浏览器可视区域的大小,它可能比浏览器的可视区域大,也可能比浏览器的可视区域小。通常这个虚拟的“视口”(viewport)比屏幕宽,会把网页挤到一个很小的窗口。
如果不显示地设置viewport,那么浏览器就会把width默认设置为980。但后果是浏览器出现横向滚动条,因为浏览器可视区域的宽度比默认的viewport的宽度小。
然后浏览器引进了 viewport 这个 meta tag,让网页开发者来控制 viewport 的大小和缩放。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| <!DOCTYPE html> <head lang=”en”> <meta charset=’utf-8′> <meta http-equiv=”X-UA-Compatible” content=”IE=edge,chrome=1″/> <meta name=”description” content=”不超过150个字符”/> <meta name=”keywords” content=””/> <meta name=”author” content=”name, email@gmail.com”/> <meta name=”robots” content=”index,follow”/> <meta name=”viewport” content=”initial-scale=1, maximum-scale=3, minimum-scale=1, user-scalable=no”> <meta name=”apple-mobile-web-app-title” content=”标题”> <meta name=”apple-mobile-web-app-capable” content=”yes”/>
<meta name=”apple-itunes-app” content=”app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL”>
<meta name=”apple-mobile-web-app-status-bar-style” content=”black”/> <meta name=”format-detection” content=”telphone=no, email=no”/> <meta name=”renderer” content=”webkit”> <meta http-equiv=”X-UA-Compatible” content=”IE=edge”> <meta http-equiv=”Cache-Control” content=”no-siteapp” /> <meta name=”HandheldFriendly” content=”true”> <meta name=”MobileOptimized” content=”320″> <meta name=”screen-orientation” content=”portrait”> <meta name=”x5-orientation” content=”portrait”> <meta name=”full-screen” content=”yes”> <meta name=”x5-fullscreen” content=”true”> <meta name=”browsermode” content=”application”> <meta name=”x5-page-mode” content=”app”> <meta name=”msapplication-tap-highlight” content=”no”>
<meta http-equiv=”pragma” content=”no-cache”> <meta http-equiv=”cache-control” content=”no-cache”> <meta http-equiv=”expires” content=”0″>
|