Why does an inline-block align to top if it has no content?

前端 未结 2 730
你的背包
你的背包 2021-01-07 03:08

I have the following simple setup:

HTML



text

tex         


        
2条回答
  •  余生分开走
    2021-01-07 03:56

    Nothing is vertically top aligned, only content is missing. If you use  everything would be fine - look here. An empty inline tag has no baseline, so its bottom edge was used for alignment.

    You have several solutions to align empty inline block tags:

    • add   (and they won't be empty anymore)
    • as BoltClock suggested, add an invisible character in :before
    • change to vertical-align: bottom

提交回复
热议问题