IE浏览器兼容性问题解决方法

如何用一行代码来解决CSS各种IE各种兼容性问题

一行代码来解决CSS在,IE6,IE7,IE8,IE9,IE10 各种兼容性问题。

在站点前端写代码的过程中,非常多时间IE各个版本号的兼容问题非常难整。如今百度与谷歌都有了一行解决这样的兼容性的代码了。如以下的。

百度办法:

百度也应用了这样的方案去解决IE的兼容问题

百度源码例如以下

<span style="color:#333333;"><!Doctype html>
<htmlxmlns=http://www.w3.org/1999/xhtmlxmlns:bd=http://www.baidu.com/2010/xbdml>
<head>
<metahttp-equiv=Content-Typecontent=“text/html;charset=utf-8″>
<metahttp-equiv=X-UA-Compatiblecontent=IE=EmulateIE7>
<title>百度一下,你就知道</title>
<script>varwpo={start:newDate*1,pid:109,page:‘superpage’}</script>
</span><span style="color:#ff6666;"><strong><meta http-equiv=X-UA-Compatible content=IE=EmulateIE7></strong></span>

能够打开百度,右键查看源代码看下!

我们能够看下文件头是否存在这样一行代码!

这句话的意思是强制使用IE7模式来解析网页代码!

Google办法:

在站点server上指定预设兼容性模式来解决这个办法。Google中ie7 – js中是一个JavaScript库(解决IE与W3C标准的冲突的JS库),使微软的Internet Explorer的行为像一个Web标准兼容的浏览器,支持很多其它的W3C标准,支持CSS2、CSS3选择器。

它修复了很多的HTML和CSS问题,并使得透明PNG在IE5、IE6下正确显示。

使IE5,IE6兼容到IE7模式(推荐)

<!–[if lt IE 7]>
<script src=”http://ie7-js.googlecode.com/svn/version/2.0(beta)/IE7.js” type=”text/javascript”></script>
<![endif]–>

使IE5,IE6,IE7兼容到IE8模式

<!–[if lt IE 8]>
<script src=”http://ie7-js.googlecode.com/svn/version/2.0(beta)/IE8.js” type=”text/javascript”></script>
<![endif]–>

使IE5,IE6,IE7,IE8兼容到IE9模式

<!–[if lt IE 9]>
<script src=”http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js”></script>
<![endif]–>



版权声明:本文博客原创文章,博客,未经同意,不得转载。

原文地址:https://www.cnblogs.com/bhlsheji/p/4656413.html