Skip to content

line-height 如何继承

js
<style>
    body {
        font-size: 20px;
        // line-height : 30px;	(p元素line-height:直接继承30px)
        // line-height : 1.5;	(p元素line-height:16乘1.5 = 24px)
        // line-height:200%	(p元素linehgiht:20 乘 200% = 40px)
    }
    p {
        background-color: #ccc;
        font-size: 16px;
    }
</style>
<p>这是一行文字</p>
  • 写具体数值,如 30px,则继承该值(30px,好理解)
  • 写比例,如 2,1.5,则继承该比例(1.5*16px,好理解)
  • 写百分比,如 200%,则继承计算出来的值(0.2*20px,难点)

基于 MIT 许可发布