在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; 可以測試一下。