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

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

    As cited above by @nkmol, its does carry default font size and line height causing unnecessary height for the parent. In some cases, line-height: 0 does solve the problem. But sometimes, in exceptional cases like an empty tag inside a parent

    I above case, just setting the font-size: 0 or line-height: 0 doesn't solve the problem as the a tag.

    vertical-align: middle;
    

    fixes the problem in such a case.

提交回复
热议问题