1.给父元素line-height:200%

div行高= 父元素的(line-height*font-size)

  1. <style>
  2. body{
  3. font-size: 20px;
  4. line-height: 200%;
  5. }
  6. div{
  7. font-size: 18px;
  8. /* 此时 div 的行高为 200%*20px =36px */
  9. }
  10. </style>
  11. <div>
  12. hello world
  13. </div>

2.给父元素line-height : 2

特殊: div行高 = line-height*(div的font-size)

<style>
  body{
    font-size: 20px;
    line-height: 2;
  }
  div{
    font-size: 18px;
    /* 此时 div 的行高为 18*2=36px */
  }
</style>
<div>
  hello world
</div>