CSS行高line-height

本文概述

  • CSS行高值
  • CSS行高示例
CSS line height属性用于定义元素中线框的最小高度。它设置内容的两行之间的差异。
它定义了内联元素上方和下方的空间量。它允许你独立于字体大小来设置行的高度。
CSS行高值【CSS行高line-height】有些属性值与CSS line-height属性一起使用。
描述
normal 这是默认值。它指定法线高度。
number 它指定一个数字乘以当前字体大小以设置行高。
length 它用于以px, pt, cm等设置行高。
% 它以当前字体的百分比指定行高。
initial 它将此属性设置为其默认值。
inherit 它从其父元素继承此属性。
CSS行高示例
< !DOCTYPE html> < html> < head> < style> h3.small { line-height: 70%; } h3.big { line-height: 200%; } < /style> < /head> < body> < h3> This is a heading with a standard line-height.< br> This is a heading with a standard line-height.< br> The default line height in most browsers is about 110% to 120%.< br> < /h3> < h3 class="small"> This is a heading with a smaller line-height.< br> This is a heading with a smaller line-height.< br> This is a heading with a smaller line-height.< br> This is a heading with a smaller line-height.< br> < /h3> < h3 class="big"> This is a heading with a bigger line-height.< br> This is a heading with a bigger line-height.< br> This is a heading with a bigger line-height.< br> This is a heading with a bigger line-height.< br> < /h3> < /body> < /html>

    推荐阅读