解决 pc上 IE 6 7 8兼容问题

IE8是有两种解析模式的,一种是IE8 Standard Modes :默认的最标准的模式,严格按照W3C相关规定,一种是IE7 Standards Modes :IE7现在用的解析网页的模式。IE7还算是不错的浏览器,如果让IE8浏览器自动切换到IE7,IE6模式,那我们就不用为IE8布局兼容问题烦恼了,而这个开关只有一行代码:
  <meta http-equiv="x-ua-compatible" content="ie=7" /> 或者<meta http-equiv="x-ua-compatible" content="ie=6" />
  <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
  <meta http-equiv="Content-Language" content="zh-cn" />
  其实就是比较霸道的让ie8以ie7的标准或者是以 ie6 的标准去解析整个页面!
  在网页的head里加入以上这段代码,用IE8访问时就会自动切换到IE7模式,如果你的网站在IE7下显示正常,那在IE8下也可以正常显示了。加入这段代码会不会影响其它的浏览器呢?不会,X-UA-Compatible是针对ie8新加的一个设置,对于ie8之外的浏览器是不识别的,所以你就放心使用吧!
  就这样一段代码就可以让你的网站轻松兼容IE8了。
  或者:
  IE8正式版出来有一段日子了,但是针对ie8正式版的CSS hack却很少,其实这是值得庆幸的,因为ie8修复了很多IE6和IE7的一些BUG,更加接近W3C标准。
  针对IE8正式版的CSS hack目前可以找到的分为2种:
  第一种:”\9″:
  基本的写法:
  1test { color: blue\9}
  这个IE6、IE7、IE8都能识别;但是IE8不能识别“*”和“_”的css hack;所以我们可以这样写hack:(转载1header {width:300px;} 2header {width:330px\9;} 3header {*width:310px;} 4header {_width:290px;} 第二种:就是使用IE的条件注释具体可以查看这里:http://www.css88.com/archives/705;其他一些css hack的测试:
  1color1{ color:#F00; color:#00F}2color2{ color:#F00; color :#00F}3color3{ color:#F00; color:#00F\9}4color4{ color:#F00; color :#00F\9}”之间有个空格*/其中:OP表示Opera,SA表示Safari参考阅读:
  http://ladysign-apps.com/blog/archives/529http://webdevelop.nitamihai.com/ie8-css-hack/<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>区别IE6、IE7、IE8、FireFox的CSS hack - www.newcss.cn</title>
  <style type="text/css">
  <!--#test,#note{margin:0 auto;text-align:center;}
  #test {width:200px;height:30px;border: 1px solid #000000;color:#fff;line-height:30px;}
  .color{background-color: #CC00FF; background-color: #FF0000\9; *background-color: #0066FF; _background-color: #009933; }
  -->
  </style>
  </head>
  <body>
  <div id="test" class="color">测试方块 hi.baidu.com/dpxdqx </div>
  <div id="note">
  <strong style="color:#009933">IE6</strong>
  <strong style="color:#0066FF">IE7</strong>
  <strong style="color:#FF0000">IE8</strong>
  <strong style="color:#CC00FF">FireFox</strong>
  </div>
  </body>
  </html>

posted @ 2015-05-27 11:06  绿罗兰  阅读(112)  评论(0编辑  收藏  举报