CSS center display inline block?

后端 未结 9 1791
误落风尘
误落风尘 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:16

    You don't need to use "display: table". The reason your margin: 0 auto centering attempt doesn't work is because you didn't specify a width.

    This will work just fine:

    .wrap {
        background: #aaa;
        margin: 0 auto;
        width: some width in pixels since it's the container;
    }
    

    You don't need to specify display: block since that div will be block by default. You can also probably lose the overflow: hidden.

提交回复
热议问题