HTML:更改 <p> 的高度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1174020/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:23:01  来源:igfitidea点击:

HTML: Change height of <p>

htmlcss

提问by core

How do I specify the height of the blank line that inserting a <p>creates?

如何指定插入<p>创建的空行的高度?

回答by Matthias Wandel

In your style sheet, or style sheet section, define this: (example)

在您的样式表或样式表部分中,定义:(示例)

p {  margin-top: 0.6em; margin-bottom: 0em; }

You can also specify it in the individual tag <p style="margin-top:.....">

您也可以在单个标签中指定它 <p style="margin-top:.....">

回答by Tyler Carter

Use CSS to mark the line height for something. E.g.:

使用 CSS 来标记某物的行高。例如:

p{
    line-height: 1.4;
}

That is for lines of text. To make a margin (The room between the

那是针对文本行的。做一个保证金(之间的空间

and everything else) define it like this.

和其他一切)像这样定义它。

  p{
        margin-top: 10px;
        margin-bottom: 10px;
        margin-left: 10px;
        margin-right: 10px;
   }

That will adjust the blank space in each direction (accordingly).

这将调整每个方向的空白空间(相应地)。

回答by Jarekczek

I'd like to note that changing the margin of a single line doesn't help, so one may not see the effects in the browser as quickly as they expect. For example:

我想指出的是,更改单行的边距无济于事,因此人们可能不会像他们预期的那样迅速地在浏览器中看到效果。例如:

<p style="margin-bottom:50px">line 50</p>
<p style="margin-top:100px">line 100</p>

results in the margin of 100 px between these lines. 50px margin overlaps the bigger one and the bigger value is the actual margin. Reducing bottom margin of the first line doesn't change anything, as well as increasing it to the value <=100px. So this works differently than line spacing beforeand afterin text editor.

导致这些行之间的边距为 100 像素。50px 边距与较大的边距重叠,较大的值是实际边距。减少第一行的底部边距不会改变任何东西,并将其增加到值 <=100px。所以这个作品比行距不同之前之后的文本编辑器

Tested in Firefox with Firebug, where yellow area denotes margins.

在带有 Firebug 的 Firefox 中进行测试,其中黄色区域表示边距。

回答by codedude

change the top and bottom margin heights.

更改顶部和底部边距高度。