改变< br>使用CSS的高度 [英] change <br> height using css

查看:188
本文介绍了改变< br>使用CSS的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里看到了问题,我无法获得任何工作答案(至少在Chrome上)。

这个问题只适用于< br> ,我知道很多其他技巧可以改变高度,但是这种情况我无法更改html

  bla 
bla

  br {
display:block;
margin-bottom:2px;
font-size:2px;
line-height:2px;
}

期望的效果:更小的线间高度。



我唯一可以工作的是 display:none ,但是所有换行符都被删除。 / p>

以下是一些使用某些技巧的小提琴 ,但看到它呈现完全相同,没有任何css。

解决方案

您无法更改 br 标签本身,因为它不是占用页面空间的元素。这只是一条创建新线的指令。



您可以使用 line-height 样式更改线高。这将改变您用空行分隔的文本块之间的距离,但也会改变文本块中行间的距离。



完整性:文本块在HTML通常使用文本块周围的 p 标签完成。这样,您可以控制 p 标记内的行高以及 p 标记之间的间距。


I have seen a question here about the same, but I can't get any of the answers to work (at least on chrome).

This question is only for <br>, I know plenty of other techniques to change the height but in this case i can't change the html.

bla<BR><BR>bla<BR>bla<BR><BR>bla

css:

br {
    display: block;
    margin-bottom: 2px;
    font-size:2px;
    line-height: 2px;
}

Desired effect: smaller inter-line height.

The only thing I can get to work is display:none, but then all line break are removed.

Here's a fiddle for it using some of the techniques, but see that it renders the exact same as without any css.

解决方案

You can't change the height of the br tag itself, as it's not an element that takes up space in the page. It's just an instruction to create a new line.

You can change the line height using the line-height style. That will change the distance between the text blocks that you have separated by empty lines, but natually also the distance between lines in a text block.

For completeness: Text blocks in HTML is usually done using the p tag around text blocks. That way you can control the line height inside the p tag, and also the spacing between the p tags.

这篇关于改变&lt; br&gt;使用CSS的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆