DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> CSS入門知識 >> CSS詳解
IE7 和 IE8 的 CSS 樣式八大差異(三):bottom、top 與 li+float
編輯:CSS詳解     

本頁整理第五與第六項差異,兩者都與定位及浮動列表有關。

5. bottom 與 top

使用絕對定位時,IE7 與 IE8 會產生些許偏移。這些偏移是整體性的,因此對版面的實際影響很小。

<div style="height:100px; width:200px; border:solid 1px black">
  <div style="background-color:Red; bottom:5px; top:5px;
              position:absolute; height:40px">
    TEST
  </div>
</div>

很難看出來吧——因為偏移量很小,不過確實是偏移了。實務上這類差異通常不需要特別處理,除非你的設計對像素精度極度敏感。

6. li + float

UL、LI 加上 float 之後,IE7 與 IE8 的差異就明顯得多:

<div>
  <ul>
    <li style="cursor:hand; float:left;">TEST1</li>
    <li style="cursor:hand; float:left;">TEST2</li>
    <li style="cursor:hand; float:left;">TEST3</li>
    <li style="cursor:hand; float:left;">TEST4</li>
    <li style="cursor:hand; float:left;">TEST5</li>
  </ul>
</div>

在 IE7 上,LI 的項目符號被取消了;IE8 則正常顯示符號,但因為元素是浮動的,後面的項目符號會蓋到前一項上。

改寫成下面的樣子之後,兩者就趨近相同了:

<div>
  <ul style="list-style-type:none">
    <li style="cursor:hand; float:left;">TEST1</li>
    <li style="cursor:hand; float:left;">TEST2</li>
    <li style="cursor:hand; float:left;">TEST3</li>
    <li style="cursor:hand; float:left;">TEST4</li>
    <li style="cursor:hand; float:left;">TEST5</li>
  </ul>
</div>

在搜尋 CSS 相異點的過程中會發現,很多網站都有這類問題——因為我們常用浮動列表來做導覽列,而這正是 IE7 與 IE8 差異最集中的地方之一。若導覽列本身不需要項目符號,與其依賴預設值,不如明確寫上 list-style-type: none,讓兩個版本的呈現一致。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved