zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    Python GIL-------全局解释器锁
    JavaScript简介
    MongoDB查询
    创建、更新和删除文档
    MongoDB基础知识
    Linux安装mysql
    函数、变量、参数
    循环语句
    控制语句
    集合
  • 原文地址:https://www.cnblogs.com/myhappylife/p/3481167.html
Copyright © 2011-2022 走看看