Html 如何减少标题之间的空间?

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

how to decrease space between headings?

htmlcss

提问by Arsal Ali

i make a div and inside i make headings but when i show then headings are outside div how to decrease heading margins? here is my code:

我做了一个 div 并且在里面我做了标题但是当我显示然后标题在 div 之外如何减少标题边距?这是我的代码:

<div id="left" style="width:300px; height:100px; float:left; margin:5px 40px 0;">
<h5 id="companyname">{{companyname}}</h5>
<h5 id="companyaddress">{{companyaddress}},{{companycity}},</h5>
<h5 id="companycountry">{{companycountry}}</h5>
</div>

and here is css:

这是css:

#companyname{
text-align:left;
font-size:13px;
}
#companyaddress{
text-align:left;
width:68%;
font-size:13px;
}
#companycountry{
text-align:left;
font-size:13px;
}

回答by Falguni Panchal

Like this

像这样

demo

演示

css

css

h5{
    margin:0;
    padding:0;
}

回答by Abhitalks

Question:

题:

how to decrease heading margins?

如何减少标题页边距?

Answer:

回答:

h5 { margin: 0px; }

回答by Vinay Pratap Singh

try adding

尝试添加

h5
{
line-height:10px;
}

i have used 10px you can use values accordingly to your need

我使用了 10px,您可以根据需要使用相应的值

Fiddle Demo

小提琴演示

Setting up the margins and padding accordingly is also a good option

相应地设置边距和填充也是一个不错的选择

h5 {
    margin:0px;
    padding:0px;
}

回答by Dinesh Kanivu

You have two Option.

你有两个选项。

  1. Increasing the Height of the div

  2. give css for h5 like this because by default h5 element takes some margin

    h5{ margin:0px}

  1. 增加div的高度

  2. 像这样为 h5 提供 css 因为默认情况下 h5 元素需要一些边距

    h5{ 边距:0px}