相關(guān)關(guān)鍵詞
關(guān)于我們
最新文章
百度,淘寶,騰訊三大巨頭HTML頁面規(guī)范分解
【兼容html5方案】
百度貼吧,百度圖片的實現(xiàn)
<!--[if lt IE 9]> <script> (function(){ var tags = ['header','footer','figure','figcaption','details','summary','hgroup','nav','aside','article','section','mark','abbr','meter','output','progress','time','video','audio','canvas','dialog']; for(var i=tags.length - 1;i>-1;i--){ document.createElement(tags[i]);} })(); </script> <![endif]--> <style> header,footer,section,article,aside,nav,figure{display:block;margin:0;padding:0;border:0;} </style>
騰訊isux研究院的實現(xiàn)
<!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]-->
淘寶- 我的淘寶頁實現(xiàn)同上,只不過是不同版本
<!-- [if lt IE 9]> <script src="http://g.tbcdn.cn//tb/mytaobao/12.12.15/common/??html5shiv-min.js"></script> <![endif]-->
不得不提的一個插件 https://github.com/aFarkas/html5shiv 在github 上達到了3453 星的高度,獲得了國內(nèi)外的廣泛認可,如果你厭煩了滿頁面的div 想盡早擁抱html5 元素,就使用它吧。
【兼容模式的選擇】
關(guān)于兼容模式
百度首頁使用的是
<meta http-equiv=X-UA-Compatible content=IE=EmulateIE7>
百度搜索頁使用的是
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
百度圖片,騰訊isux研究院,淘寶收藏頁使用的是
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
X-UA-Compatible 這是個是IE8的專用標記,用來指定IE8瀏覽器去模擬某個特定版本的IE瀏覽器的渲染方式
chrome=1寫法可以達到的效果是如果安裝了GCF,則使用GCF來渲染頁面,如果未安裝GCF,則使用最高版本的IE內(nèi)核進行渲染。
百度首頁那么點東西他當然不在乎用哪種模式,更多地去照顧老式瀏覽器; 搜索頁傾向于速度有GCF的時候更愿意使用chorme渲染。
不得不吐槽,國內(nèi)各的銀行支付時的兼容支持,由此第三種得到大家的共同認可似乎也無可厚非。
【移動至上】
騰訊isux研究院的實現(xiàn)
<!-- Mobile Specific Metas ================================================== --> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes" />
淘寶主頁的實現(xiàn)
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" /> <meta content="yes" name="apple-mobile-web-app-capable" />
這里沒貼百度的,不代表百度不重視這一塊,反而太重視了,19億$買了91無線 再加上 百度App 貼吧App 音樂App 圖片APP ... 全有了。
【建議升級】
<!--[if lt IE 8]> <div class="g_tips"> <p>已經(jīng)有超過90%的用戶使用更高版本 <a target="_blank" title="下載Chrome" href="http://www.google.com/chrome/">Google Chrome</a> 或 <a target="_blank" href="http://www.microsoft.com/zh-cn/download/ie.aspx?q=internet+explorer">Internet Explorer</a> 體驗到了更精彩的頁面,你還不試試?</p> </div> <![endif]--> <style> .g_tips{background:#FFF691;color:#010101;text-align:center;height:40px;line-height:40px;font-family:'STHeiti','\5fae\8f6f\96c5\9ed1'}.g_tips a{color:#676767;padding:0 2px;zoom:1} </style>
什么,連ie8都不是? 無法容忍啊,建議你早點換吧!
【參考模版】
<!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>頁面名稱</title> <meta name="keywords" content=""/> <meta name="description" content=""/> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <!-- Mobile Specific Metas ================================================== --> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes" /> <!-- css ================================================== --> <link rel="shortcut icon" href="http://www.yunos.com/favicon.ico"> <link rel="stylesheet" href="http://m.alicdn.com/css/index.css"/> <style>/* css */</style> </head> <body> <!--[if lt IE 8]> <div class="g_tips"> <p> 已經(jīng)有超過90%的用戶使用更高版本 <a target="_blank" title="下載Chrome" href="http://www.google.com/chrome/">Google Chrome</a> 或 <a target="_blank" href="http://www.microsoft.com/zh-cn/download/ie.aspx?q=internet+explorer">Internet Explorer</a> 體驗到了更流暢更精彩的頁面,你還不試試? </p> </div> <![endif]--> <h1>300,000,00</h1> <script src="js/index.js"></script> <script>// js </script> </body> </html>
<html lang="zh-CN"> 性屬說明這個html內(nèi)容是以中文為顯示和閱讀基礎(chǔ),多語言的網(wǎng)站建議添加。
- 通常情況下CSS放文檔開始,腳本放在文檔末尾我想不用解釋太多
- 如果一個頁面足夠簡單,寫在頁面上是完全 OK 的,特別是一些簡單的專題,但是項目上需謹慎使用
頁面全局變量命名隨記 PDC FP PageInfo window.g_config (function(){window.PDC={}})();
【CDN加速】【dataUrl】【css spirte】【按需加載和loader機制】【壓縮檢查發(fā)布】
作為一個前端開發(fā),這些你做了嗎?