float后怎么居中

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

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

第一种方案:spa

<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>

 

 第二种方案(推荐)code

<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>
相关文章
相关标签/搜索