Why does inline-block cause this div to have height?

前端 未结 7 1063
遇见更好的自我
遇见更好的自我 2020-11-27 16:25

jsFiddle Demo

I cannot seem to figure out why using display:inline-block would cause this

element to
相关标签:
7条回答
  • 2020-11-27 16:51

    Ok as already mentioned very briefly in the comments:

    inline-block

    This value causes an element to generate an inline-level block container. The inside of an inline-block is formatted as a block box, and the element itself is formatted as an atomic inline-level box.

    inline

    This value causes an element to generate one or more inline boxes.

    The most important part for this topic would be that the element itself get's formatted not just the content. Every inline-block element will be seen as atomic inline box and thus take up space.

    Source: http://www.w3.org/TR/CSS2/visuren.html#inline-boxes

    0 讨论(0)
提交回复
热议问题