How to vertically align 2 different sizes of text?

后端 未结 8 626
终归单人心
终归单人心 2020-12-02 13:48

I know to vertically align text to the middle of a block, you set the line-height to the same height of the block.

However, if I have a sentence with a word in the m

8条回答
  •  一生所求
    2020-12-02 14:34

    The functionality you are seeing is correct because the default for "vertical-align" is baseline. It appears that you want vertical-align:top. There are other options. See here at W3Schools.

    Edit W3Schools has not cleaned up their act and still, appear, to be a shoddy (at best) source of information. I now use sitepoint. Scroll to the bottom of the sitepoint front page to access their reference sections.

提交回复
热议问题