Which magic CSS causes the difference of text-vertical-align between <button> and
?

后端 未结 3 1453
闹比i
闹比i 2021-01-04 02:06

I found that the text inside of

3条回答
  •  太阳男子
    2021-01-04 02:36

    I think you may consider one of the following solutions

    Solution #1

    Add these to the div style

    display: table-cell;

    vertical-align: middle;

    If you still need to use inline-block display, you can use nested div, the parent div will be displayed as (inline-block), the child div will be displayed as (table-cell) and that's where you middle the text.

    Solution #2

    You can set the div padding and line height dynamically using jQuery .. and this will be done on the run time, and will be adjusted based on the size of the content inside the div. you can check this question jquery set line-height equal to parent container height

提交回复
热议问题