Vertically center text which is beside a much larger , both inside a

前端 未结 2 1525
盖世英雄少女心
盖世英雄少女心 2021-01-20 02:34

I am trying to vertically center some text in a element, in relation to a much larger that is a sibling of the first one.

相关标签:
2条回答
  • 2021-01-20 03:26

    If you want the left one-line text to align to the first line of multi-line text on the right, you need to use vertical-align: baseline instead of vertical-align: middle along with display: table-cell. .previewLabel doesn't need a set line-height.

    DEMO

    .previewLabel {
        vertical-align: baseline;
    }
    
    span {
        display:table-cell;
    }
    
    0 讨论(0)
  • 2021-01-20 03:40

    Adding vertical-align:middle to both .previewLabel and .previewText will work just fine.

    And here is a fiddle for proof: http://jsfiddle.net/pavloschris/5chXG/4/

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