CSS center display inline block?

后端 未结 9 1843
误落风尘
误落风尘 2020-11-22 08:25

I have a working code here: http://jsfiddle.net/WVm5d/ (you might need to make the result window bigger to see the align center effect)

Question

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 09:14

    Try this. I added text-align: center to body and display:inline-block to wrap, and then removed your display: table

    body {
        background: #bbb;
        text-align: center;
    }
    
    .wrap {
        background: #aaa;
        margin: 0 auto;
        display: inline-block;
        overflow: hidden;
    }
    

提交回复
热议问题