IE6 兩個div有間隙的問題(IE 3px bug)解決方案

來源:互聯網
上載者:User

 在IE7中兩個div是緊挨著的,但是在IE6中會出現兩個div之間出現3px左右的間隙,這就是傳說中的“IE 3px bug”。

 

解決方案如下:

 

且看樣本:

<html xmlns="http://www.w3.org/1999/xhtml"><br /><head><br /><meta http-eq<a href="http://www.mjjzz.com/CSS/ui/" mce_href="http://www.mjjzz.com/CSS/ui/" target="_blank" class="keylink">ui</a>v="Content-Type" content="text/html; charset=utf-8" /><br /><title>ChaiChunyan fixed ie 3px bug demo</title><br /><mce:style type="text/css"><!--</p><p>#left {<br />float:left;<br />width:200px;<br />height:100px;<br />background:#f00;<br />}<br />#right {<br />float:left;<br />width:200px;<br />height:100px;<br />background:#fc0;<br />}<br />--></mce:style><style type="text/css" mce_bogus="1"><br />#left {<br />float:left;<br />width:200px;<br />height:100px;<br />background:#f00;<br />}<br />#right {<br />float:left;<br />width:200px;<br />height:100px;<br />background:#fc0;<br />}</style><br /></head><br /><body><br /><div id="left">left</div><br /><div id="right">right</div><br /></body><br /></html>

 

注意:

1. 此方法不用再使用以前調換兩個div位置,將第二個div的float 設定為right

2. 如果這兩個層包含在同一個層下邊,注意父節點的層不要再使用 float: left

 

此解決方案 適用IE6+ , FF 2.0+

 

網上還有提供 相對IE6定義#left margin-right:-3px; 可以測試一下。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.