Html 如何去除段落之间的空格 (p)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18798147/
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
How to remove the space between paragraphs (p)
提问by Ashis Kumar
How can I remove spaces between paragraphs in HTML?
如何删除 HTML 中段落之间的空格?
<p class="first">This is a small demo</p>
<p class="second">This is second demo</p>
回答by Ashis Kumar
You can use margin: 0;
to remove the spaces.
您可以使用margin: 0;
删除空格。
p { margin: 0; }
If this still don't work, try making it !important
如果这仍然不起作用,请尝试制作 !important
p { margin: 0 !important; }
Check this http://jsfiddle.net/zg7fP/1/
回答by Farax
Try setting margin-bottom: 0
on the top paragraph and margin-top: 0
to the bottom paragraph
尝试设置margin-bottom: 0
上段和margin-top: 0
下段
or you can use a div instead of the paragraph
或者您可以使用 div 代替段落
回答by Amit Patel
You can set the default margin to zero with CSS:
您可以使用 CSS 将默认边距设置为零:
p {
margin: 0px;
}
回答by Diego
You should use p {margin: 0 auto;}
你应该使用 p {margin: 0 auto;}
In case you want to add indentation (recommended if you remove spaces between paragraphs) a good technique is:
如果您想添加缩进(如果您删除段落之间的空格,建议您这样做)一个好方法是:
p + p {text-indent: 1.25em;}
回答by jerryurenaa
In case you are using bootstrap this is the solution: the class m-0
如果您使用引导程序,这是解决方案:类 m-0
<p class="m-0">text</p>
回答by racemi
Try to use line-height: 100%;
or other percentage you think it feets well on your HTML.
尝试使用line-height: 100%;
您认为适合您的 HTML 的其他百分比。
回答by Mark
put both inside a single set of p and seperate with br
将两者放在一组 p 中并用 br 分开