shpasspass
V2EX  ›  问与答

求教一个text-align:center究竟什么时候是居中的?

  •  
  •   shpasspass · Jun 12, 2013 · 3088 views
    This topic created in 4892 days ago, the information mentioned may be changed or developed.
    就是这段html,我已经给.bb进行text-align:center了,但为什么无效呢?
    最混乱的就是我自己写html时加text-align:center,有时候会居中,有时候不会居中,到底什么样的情况下,text-align:center才会生效呢?


    <!DOCTYPE html>
    <style>
    .aa{
    float:left;
    }
    .bb{
    text-align:center;
    }
    </style>

    <div class="aa">

    <div class="bb">
    我真的想居中,但就是无法居中
    </div>

    </div>
    2 replies  •  1970-01-01 08:00:00 +08:00
    guchengf
    guchengf
    Jun 12, 2013❤️1
    1
    没有参考物怎么居中,两端得有边界才行啊
    给.aa 加上 width:100%;
    再看效果
    cutehalo
    cutehalo
    Jun 12, 2013
    2
    float以后div的宽度就不是100%了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2914 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 12:38 · PVG 20:38 · LAX 04:38 · JFK 07:38
    ♥ Do have faith in what you're doing.