inline-block div with and without text not vertically aligned

后端 未结 1 633
故里飘歌
故里飘歌 2020-12-09 13:58

I have two divs side by side. Both have the same size and display: inline-block. The only difference between the two is, the first one has some tex

1条回答
  •  悲&欢浪女
    2020-12-09 14:37

    Inline-block boxes are,by default vertically aligned such that the baseline of the inline-block box aligns to the baseline of the line box in which it is rendered.

    The baseline of an inline-block box with one line of text, is the baseline of that line. More generally, the baseline of an inline-block is the baseline of the last line of text that it contains. But that means that there is no baseline for an inline-block that contains no text.

    In such a situation a fall back rule kicks in, and the bottom of the inline-block box is placed on the baseline of its line box.

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