Html 如果我想控制行之间的高度,<br /> 的替代方法是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10996237/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the alternative to <br /> if I want to control the height between lines?
提问by DavidW
In following example:
在以下示例中:
Line1 <br /> Line2
I'm using <br />
to force Line2 to go to next line, but as far as I know there is no cross browser friendly way of setting the height of br. What is an alternative method I could use?
我正在使用<br />
强制 Line2 转到下一行,但据我所知,没有跨浏览器友好的设置 br 高度的方法。我可以使用的替代方法是什么?
回答by GuillaumeS
Use differents blocks :
使用不同的块:
<p>Line1</p>
<p>Line2</p>
回答by Ashwin
Normally, using <br />
is old way of breaking a line.
You should use <p>, <div>
or some block level elements and give them top or bottom margins.
通常,使用<br />
是断线的旧方法。您应该使用<p>, <div>
或 一些块级元素并为它们提供顶部或底部边距。
p {
margin-top:5px;
margin-bottom:5px
}
回答by Digitalis
Using CSS you can control the line-height
property of any element.
使用 CSS,您可以控制line-height
任何元素的属性。
someElement {
line-height:12px;
}
Now you may simply set this for an element, or use it on the entire HTML to provide uniformity across the document. This is safe, cross-browser compatible and easy to use.
现在您可以简单地为一个元素设置它,或者在整个 HTML 上使用它来提供整个文档的统一性。这是安全、跨浏览器兼容且易于使用的。
回答by Ravi Jain
You can use css line-height
property along with <br/>
tag to control spacing between lines.
您可以使用 cssline-height
属性和<br/>
标签来控制行之间的间距。
<style>
.small
{
line-height:100px;
}
</style>
<p class="small">
This is a paragraph with a smaller line-height.<br />
This is a paragraph with a smaller line-height.<br />
This is a paragraph with a smaller line-height.<br />
This is a paragraph with a smaller line-height.<br />
</p>
回答by Syed Priom
- I add a
<div>
, best way for me, with CSS margin. Or, - The
<p>
tag.
- 我添加了一个
<div>
对我来说最好的方法,带有 CSS 边距。或者, - 该
<p>
标签。
回答by yogi
Use padding
& / or margin
css attributes.
使用padding
& / 或margin
css 属性。