float后怎么居中

我们在用css float的时候,如何让文本水平居中真的很麻烦,

[float]使div(或者其他标签)的宽度自适应其内容,但它却有个弊端:无法居中。
[display:inline-block]也有同样的特性,并且可以居中,但连续几个这样的东东,之间却会出现空格。

第一种方案:

<html>
    <body style="text-align:center">
        <div style="margin:0 auto;">
          <div style="float:left">123243</div>
          <div style="float:left">6576876</div>
          <div style="float:left">2433665</div>
        </div>
    </body>
</html>

 

 第二种方案(推荐)

<html>
    <body style="text-align:center">
        <div style="display:inline-block; *display:inline; zoom:1;">
          <div style="float:left">123243</div>
          <div style="float:left">6576876</div>
          <div style="float:left">2433665</div>
        </div>
    </body>
</html>

 

posted @ 2013-12-18 22:08  huanshare  阅读(13832)  评论(0编辑  收藏  举报