html - 减少跨度中的行间距

标签 html css

查看下面的跨度:

<div style=" position:absolute; top:37.6pt; left:0.8pt; background-color:; border:0pt solid black; width:234pt;">
<div  align="left" ><span style=" white-space:pre-wrap;  font:normal 8pt Arial; color:rgb(0,0,0);">Your statement shows claims for medical care only after we've received and processed the claim. The claim in question may not have been received yet or it may not be finalized. There may be instances where your claims are not showing up because Health Statements have recently been added to your plan.</span></div> 
</div> 

默认情况下,Span 显示的行间距太大,我想将行间距设置为如下文本所示:

<div style=" position:absolute; top:37.6pt; left:0.8pt; background-color:; border:0pt solid black; width:234pt;">
<div  align="left" ><div style=" white-space:pre-wrap;  font:normal 8pt Arial; color:rgb(0,0,0);">Your statement shows claims for medical care only after we've received and processed the claim. The claim in question may not have been received yet or it may not be finalized. There may be instances where your claims are not showing up because Health Statements have recently been added to your plan.</div></div> 
</div> 

我面临的限制是我不能使用“div”而不是 span,我也不能使用“display”属性,所以有什么方法可以在没有 display 属性的情况下减少 span 中的行间距。理想情况下是“line” -height"属性,但这似乎不起作用..

最佳答案

ideally "line-height" property, but that doesn't seem to work..

如果您不在跨度上设置行高,而是在父容器上设置行高,我会工作:

<div style="width: 400px;">
    <div align="left" style="line-height: .4em;">
        <span style="white-space: pre-wrap; font: normal 8pt Arial;">Your statement shows claims for medical care only after we've received and processed the claim. The claim in question may not have been received yet or it may not be finalized. There may be instances where your claims are not showing up because Health Statements have recently been added to your plan.</span>
    </div>
</div>

UPD. @sai kumar 发现了有关 CSS 规则顺序重要性的有趣细节。为了 line-height 在 span 上工作,它应该放在 font 属性之后。顺序在这里很重要,因为 font 是一个组合属性,其中还包含 line-height。因此在这种情况下,在 line-height 之后定义的 font 将使用默认值 line-height: normal 覆盖它。

关于html - 减少跨度中的行间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28298034/

相关文章:

javascript - Windows 8 桌面应用程序 (HTML + javascript) 的视频捕获。不是来自网络摄像头

javascript - 如何用jQuery获取li中隐藏的值?

javascript - 语义 UI Accordion 重叠位置固定元素

javascript - 加载时自动点击 youtube 播放按钮

html - 如何在访问/激活子元素时更改父元素的颜色

javascript - 如何在javascript中使用if条件来处理json?

javascript - 使用 Javascript 将 HTML 转换为其安全实体

html - 为什么这个按钮和它旁边的按钮不在同一行?

html - 在 IE 中如何设置表格中的单元格高度以填充窗口?

css - 为什么段落文本在默认的 CSS3 多列网站布局中没有正确对齐?