`margin:auto;` doesn't work on inline-block elements

前端 未结 3 1356
野的像风
野的像风 2020-12-02 23:32

I have a "container" div to which I gave margin:auto;.

It worked fine as long as I gave it a specific width, but now

3条回答
  •  孤城傲影
    2020-12-02 23:48

    For elements with property display: inline-block; A computed value of 'auto' for 'margin-left' or 'margin-right' becomes a used value of '0'. [reference: CSS2§10.3.9]

提交回复
热议问题