V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
shpasspass
V2EX  ›  问与答

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

  •  
  •   shpasspass · Jun 12, 2013 · 2796 views
    This topic created in 4715 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
        1
    guchengf  
       Jun 12, 2013   ❤️ 1
    没有参考物怎么居中,两端得有边界才行啊
    给.aa 加上 width:100%;
    再看效果
    cutehalo
        2
    cutehalo  
       Jun 12, 2013
    float以后div的宽度就不是100%了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3474 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 135ms · UTC 11:18 · PVG 19:18 · LAX 04:18 · JFK 07:18
    ♥ Do have faith in what you're doing.