Html 在html中垂直减少标题和段落之间的空间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34899077/
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
Decrease the space between header and paragraph vertically in html
提问by krishna mohan
I want to decrease the vertical spacing between header and paragraph.
我想减少标题和段落之间的垂直间距。
<td style="width:427px;">
<h2 style="color:#156CA4">Quotation</h2>
<p style="color:#00A651">abc Technologies Pvt Ltd</p>
</td>
回答by Smithy
Try adjusting the line height property using CSS. I would recommend giving it an id though if you only want it to affect this p tag in particular
尝试使用 CSS 调整行高属性。我建议给它一个 id 但如果你只希望它特别影响这个 p 标签
p {
line-height: 0px;
}
There is also the possibility of negative margins (which isn't considered best practice, but will work in your case):
也有可能出现负边距(这不被认为是最佳实践,但适用于您的情况):
p {
margin-top:-5px;
}
回答by Hampus
回答by ketan
Simple use following css will remove default all padding and margin. Because here h2 use default spacing.
简单使用以下 css 将删除默认的所有填充和边距。因为这里 h2 使用默认间距。
*{
margin:0;
padding:0;
}
Previous result:
上一个结果:
<td style="width:427px;">
<h2 style="color:#156CA4">Quotation</h2>
<p style="color:#00A651">abc Technologies Pvt Ltd</p>
</td>
New working Result:
新的工作结果:
*{
margin:0;
padding:0;
}
<td style="width:427px;">
<h2 style="color:#156CA4">Quotation</h2>
<p style="color:#00A651">abc Technologies Pvt Ltd</p>
</td>
回答by Gugan
Use margin-bottom style inside h2
在 h2 中使用 margin-bottom 样式
margin-bottom:-10px;
To decrease space we should use values in negative.
为了减少空间,我们应该使用负值。
回答by Ashish Patel
Add this style below your html, i thing it can be usefull
将此样式添加到您的 html 下方,我认为它很有用
<style>
h2, p {
margin: 0;
}
</style>