How to vertically align 2 different sizes of text?

后端 未结 8 591
终归单人心
终归单人心 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:48

    the two set of text must have the same fixed line-height and the vertical-align set

     span{
         vertical-align: bottom;
         line-height: 50px;
    }
    
    0 讨论(0)
  • 2020-12-02 14:51

    Try vertical-align:middle; on inline containers?

    EDIT : it works but all your text must be in an inline container, like this :

        <div style="height:100px; line-height:100px; background:#EEE;">
            <span style="vertical-align:middle;">test</span>
            <span style="font-size:2em; vertical-align:middle;">test</span>
        </div>

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