Home  >  Q&A  >  body text

求问关于height和line-height的区别?越详细越好?

在布局里面经常会用到这两个的,无法理解这个区别,越详细越好

哈哈哈哈哈哈2832 days ago1056

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-09-30 23:24:56

    Can I ask about the difference between height and line-height? The more detailed the better? -PHP Chinese website Q&A-May I ask about the difference between height and line-height? The more detailed the better? -PHP Chinese website Q&A

    Please watch and learn.

    reply
    0
  • 阿神

    阿神2016-12-21 11:53:24

    height——设置元素的高度。
     line-height——设置行间的距离(行高)。
    如:你给一个<h1 class="test">这个是大标题</h1>设置相关属性,

    .test{
        width:200px;
        height:30px;
        line-height:30px;
    }

    height属性可用百分比、像素值设置。如:

    .test{
        height:50%;
      }

    line-heigh属性会影响行框的布局。在应用到一个块级元素时,它定义了该元素中基线之间的最小距离而不是最大距离。line-height 与 font-size 的计算值之差(在 CSS 中成为“行间距”)分为两半,分别加到一个文本行内容的顶部和底部。可以包含这些内容的最小框就是行框。

    reply
    1
  • Cancelreply