跳到主要内容

line-height的继承

line-height: number

body {
font-size: 40px;
line-height: 1.5;
}
p {
font-size: 20px;
}
/* 此时 p 的行高是 1.5 * 20px = 30px; */

line-height: 百分比

body {
font-size: 40px;
line-height: 150%;
}
p {
font-size: 20px;
}
/* 此时 p 的行高是 父元素 计算之后的 150% * 40px = 60px; */

line-height: em单位,

body {
font-size: 40px;
line-height: 1.5em;
}
p {
font-size: 20px;
}
/* 此时 p 的行高是 父元素 计算之后的 1.5 * 40px = 60px; */

所以,想要line-height随着font-size缩放,早好采用数值