使用标签时行高不起作用。为什么?

时间:2012-09-10 17:43:29

标签: css

<div style="line-height:25px;">
First line of the content<br />
Second line of the content<br />
Third line of the content<br />
</div>

<div>中使用break标记时,line-height属性不适用于任何属性:

line-height:20px;
line-height:100%;
line-height:1.5;

现在,三行显示的是默认行高,而不是指定的line-height 25px。但是如果<div>在行之间没有包含断点标记,则行高可以正常工作。如何覆盖这个?

1 个答案:

答案 0 :(得分:1)

由于<br />是内联元素,因此您需要将line-height应用于<p>等块元素。

<p style="line-height: 20px;">
This is some text<br />with a break tag.
</p>

您想查看有关将<br />转换为块元素的this问题。

相关问题