1

HTML:

<div class="wrapper">
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
</div>

CSS:

.wrapper{
    width:1000px;
    text-align:center;
    float:left;    
}

.wrapper .box{
    width:300px;
    height:50px;
    display:inline-block;
    background:#F00;
    margin:0 10px 10px 0;
    overflow:hidden;
 }

我想像这样将所有 div 集中在包装 div 中;在此处输入图像描述

以上代码在 IE8、IE9、Chrome、Safari、Opera、FF 中运行良好,但在 IE7 中无法运行。当我在 IE7 中打开页面时,页面如下所示;

在此处输入图像描述

如果我使用 float:left,问题似乎解决了,但所有 div 都基于左边。我该如何解决这个问题?

http://jsfiddle.net/eBxFX/2/

4

1 回答 1

4

内联块在 IE7 中不起作用。

您必须使用 zoom:1 和 display:inline 作为 hack 或没有来自不同 css 的 hack 仅适用于 ie7。

.wrapper .box{
    width:300px;
    height:50px;
    display:inline-block;
    *display: inline;
    *zoom:1;
    background:#F00;
    margin:0 10px 10px 0;
    overflow:hidden;
}

http://jsfiddle.net/eBxFX/4/

于 2013-01-22T15:28:52.353 回答