容器div额外保证金ie6

时间:2011-07-02 13:08:13

标签: html css

<div id="container">
    <div id="content">
        <div class="halfLeft"></div>
        <div class="halfRight"></div>
    </div>
</div>

#container{ width:960px;margin:auto; background-image:url(../img/contentbg.jpg);}
.halfLeft{font: 1.5em BrushcutRegular; background:url(../img/halfbg.png) no-repeat;margin:12px 0px 12px 12px;float:left;width:468px;height:336px;}
.halfRight{font: 1.5em BrushcutRegular; background:url(../img/halfbg.png) no-repeat;margin:12px 12px 12px 0px;float:right;width:468px;height:336px;}

由于某种原因,这使得#container在IE6左侧添加额外的12px ...

任何想法有什么不对?

2 个答案:

答案 0 :(得分:0)

尝试将display: inline;添加到.halfLeft.halfRight

更多信息:The IE5/6 Doubled Float-Margin Bug

答案 1 :(得分:0)

我认为你应该为#content添加一些样式:

padding: 12px;
overflow: hidden; /* Floating fix for modern browsers */
zoom: 1; /* Floating fix for IE */

从.halfLeft和.halfRight中移除边距。