日期:2014-05-16  浏览次数:20583 次

css行高line-height的介绍

?

一、line-height语法

?

?

line-height属性的具体定义列表如下:

?

语法: line-height : normal | <实数> | <长度> | <百分比> | inherit

?

?

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

?

?

可能的值:

?

说明
normal 默认,设置合理的行间距。
number 设置数字,此数字会与当前的字体尺寸相乘来设置行间距。相当于倍数
length 设置固定的行间距。
% 基于当前字体尺寸的百分比行间距。
inherit 规定应该从父元素继承 line-height 属性的值。

?

?

?

二、定义line-height的方式

?

?

1、line-height可以被定义为normal。

?

body { line-height:normal; }
body { line-height:normal; }

?

?

2、line-height可以被定义为继承

?

?

p { line-height:inherit; }

?

?

?

3、line-height可以使用一个百分比的值

?

?

p { line-height:120%; }

?

?

?

4、line-height可以被定义为一个长度值(单位px、em等)

?

?

p { line-height:20px; }

?

?

参考资料:????? css行高line-height的用法???? http://www.studyofnet.com/news/273.html