IE6′s Bug系列之雙倍margin

來源:互聯網
上載者:User

在ie6中布局時,當子項目為浮動,而且具有跟浮動方向相同的margin時,第一個子項目即緊靠父元素的元素會產生該方向上雙倍的margin值。如下所示:

<style type="text/css">*{ margin: 0;padding: 0;}li{ list-style: none;}ul{ overflow:hidden;zoom:1;background: green;}li{ width: 98px;height: 198px;background: red;border: #000 1px solid;margin-right: 20px;float: right;}</style><body>        <ul>            <li></li>            <li></li>            <li></li>            <li></li>            <li></li>            <li></li>        </ul></body>

解決方案:為子項目添加樣式{display:inline;}

◆注意:

這個現象僅當塊級對象設定了浮動屬性後才會出現,內聯對象(行級對象)不會出現此問題。並且只有設定左邊距和右邊距的值才會出問題,上下邊距不會出現問題。使用display:inline方法僅限於使用float時使用,否則顯示會出現問題。多個子塊在父塊中使用float時,同行顯示的多個子塊只需要第一個使用display:inline

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.