IE6IE9兼容性问题列表及解决办法_补遗漏之二:CSS区分大小写,Style中height需要加px

经过一段时间的实践,在“IE6-IE9兼容性问题列表及解决办法总结”的基础上,再补充2点:
http://www.cnblogs.com/liuzhendong/archive/2012/04/09/2438502.html

补充在:第二章:CSS, 第一节:IE6-IE7更新

具体内容:

4. CSS样式区分大小写。
如下代码,在IE6下,CSS样式类名不分大小写,但从IE7开始,区分大小写了, IE8和IE9也区分大小写,也就是说,我们CSS样式类和使用它的地方,必须保持完全一致。

<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
 <style type="text/css">
.field
{
 background-color:blue;  /* ie 9*/
 }
</style>
</head>
<body >
 <p class="Field"> this is for div1</p>
 <p style="background-color:blue"> this is for div2 </p>
</body>
</html>

5.Style中的height, width结尾需要输入单位,如px
如下代码,在ie6下,能够读取到style中定义的height=30,但从ie7开始,就必须在height:30后面加上单位px了,否则,读取不出来height值。

<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=6" />
    <script type="text/javascript">
        function load1() {
            alert(document.getElementById("p1").style.height);
        }
    </script>
</head>
<body onload="load1()" >
<p id="p1" style="background-color:blue; height:30"> this is for div2 </p>
</body>
</html>

原文地址:https://www.cnblogs.com/liuzhendong/p/2633197.html