IE6-IE9相容性問題列表及解決辦法_補遺漏之二:CSS區分大小寫,Style中height需要加px

來源:互聯網
上載者:User

經過一段時間的實踐,在“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>

 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.