height vs line-height styling

后端 未结 6 1534
北恋
北恋 2020-12-13 13:14

What is the difference between using these two when dealing with text that will never be more than a single line? They both can produce similar results on the screen from w

6条回答
  •  北海茫月
    2020-12-13 13:53

    Assuming the text is smaller than the container:

    Setting the line-height on the container specifies the minimum height of line-boxes inside it. For 1 line of text, this results in the text vertically centered inside the container.

    If you set height on the container then the container will grow vertically, but the text inside it will start on the first (top) line inside it.

提交回复
热议问题