Is line-height: 1.4 the same as line-height: 140%?

前端 未结 3 1932
萌比男神i
萌比男神i 2020-12-10 20:25

Is using a line-height value of 1.4 the same as using a line-height value of 140%? In other words, can we consider unitless value the same as perce

3条回答
  •  囚心锁ツ
    2020-12-10 21:15

    No.

    The unitless values are calculated based on the element's font-size:

    (unitless) The used value is this unitless multiplied by the element's own font size. The computed value is the same as the specified . In most cases, this is the preferred way to set line-height and avoid unexpected results due to inheritance.

    Conversely, percentage-based values merely adjust the line-height based on the calculated line-height. Thus, if you have a calculated line-height of 10px, it will convert to 14px if you use line-height: 140%.

提交回复
热议问题