HTML+CSS入门 百度,淘宝,腾讯三大巨头HTML页面规范分解
沉沙 2018-05-29 来源 : 阅读 960 评论 0

摘要:本文通过对百度,淘宝,腾讯三大巨头HTML页面规范分解,帮助大家解析HTML开发的潮流,希望阅读本篇文章以后大家有所收获,帮助大家HTML+CSS入门。

【兼容html5方案】

百度贴吧,百度图片的实现

<!--[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研究院的实现
<!--[if lt IE 9]>
 <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
 
淘宝- 我的淘宝页实现同上,只不过是不同版本
<!-- [if lt IE 9]>
<script src="//g.tbcdn.cn//tb/mytaobao/12.12.15/common/??html5shiv-min.js"></script>
<![endif]-->
 
不得不提的一个插件 https://github.com/aFarkas/html5shiv 在github 上达到了3453 星的高度,获得了国内外的广泛认可,如果你厌烦了满页面的div 想尽早拥抱html5 元素,就使用它吧。
 
【兼容模式的选择】
关于兼容模式
百度首页使用的是
<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内核进行渲染。
百度首页那么点东西他当然不在乎用哪种模式,更多地去照顾老式浏览器; 搜索页倾向于速度有GCF的时候更愿意使用chorme渲染。
不得不吐槽,国内各的银行支付时的兼容支持,由此 IE=Edge,使 IE 以最新模式渲染得到大家的共同认可似乎也无可厚非。
 
【移动至上】
腾讯isux研究院的实现
<!-- 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" />
 
淘宝主页的实现
<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" />
 
不论 ios、Anroid 还是云OS,最重要的都是 viewport 的设置
width=device-width 宽度等于设备宽度,初始化比例为1,禁止用户缩放。
ios 下通过 apple-mobile-web-app-capable 开始桌面全屏模式
这里没贴百度的,不代表百度不重视这一块,反而太重视了,19亿$买了91无线 再加上 百度App 贴吧App 音乐App 图片APP ... 全有了。
 
 
【建议升级】
<!--[if lt IE 8]>
<div>
    <p>已经有超过90%的用户使用更高版本 <a target="_blank" title="下载Chrome" href="//www.google.com/chrome/">Google Chrome</a> 或 <a target="_blank" href="//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="//www.yunos.com/favicon.ico">
    <link rel="stylesheet" href="//m.alicdn.com/css/index.css"/>
    <style>/* css */</style></head>
 <body>
    <!--[if lt IE 8]>
    <div>
        <p>
            已经有超过90%的用户使用更高版本
            <a target="_blank" title="下载Chrome" href="//www.google.com/chrome/">Google Chrome</a>
            或
            <a target="_blank" href="//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> 性属说明这个html内容是以中文为显示和阅读基础,多语言的网站建议添加。
通常情况下CSS放文档开始,脚本放在文档末尾我想不用解释太多
如果一个页面足够简单,写在页面上是完全 OK 的,特别是一些简单的专题,但是项目上需谨慎使用
 
页面全局变量命名随记 PDC FP PageInfo window.g_config (function(){window.PDC={}})();

本文由职坐标整理并发布,了解更多内容,请关注职坐标WEB前端HTML/CSS频道!

本文由 @沉沙 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved

208小时内训课程