Line height default value if font size is 100%

后端 未结 5 1690
故里飘歌
故里飘歌 2021-01-03 21:02

I must override the body style of my page:

body{
    font-size:14px;
    line-height:20px;
}

override:

body{
    font-size:         


        
5条回答
  •  孤城傲影
    2021-01-03 21:29

    Set a unitless value of 1, which will multiply the calculated font-size (i.e. how big the font turns out to be) with 1, making for a high-enough line-height.

    You can also use 1.5 for a little more spacing.

    So to finish your code it would be

    body{
      font-size:100%;
      line-height: 1.5;
    }
    

    See the part on at https://developer.mozilla.org/en-US/docs/CSS/line-height for more details. Using a unitless number is stated as the preferred way of setting line-height.

提交回复
热议问题