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

前端 未结 7 1155
遇见更好的自我
遇见更好的自我 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:36

    display:inline-block has different behavior than display:block. While block create a box element, inline block creates a box but it add some surrounding content as if it were a single inline element. This surrounding content could be the source of your issue. I think unless you have a very specific reason to use inline-block you should use display:block.

提交回复
热议问题