删除段落和无序列表之间的空间 [英] remove space between paragraph and unordered list
问题描述
< p>文本< / p>
< ul>
< li> One< / li>
< / ul>
< p>文本2< / p>
如何删除段落和列表之间的垂直空间。
更具体地说-仅在后面跟随无序列表时,如何减少p标签的底部边距/填充。我在这里看到的所有答案都删除了所有p标签之后的空格-并不是要求的。
您可以使用CSS选择器
p + ul {
margin-top:-10px;
}
这可能会有所帮助,因为 p + ul
表示选择< p>
元素之后的任何< ul>
元素。
您通常必须对此进行调整,以适应< p>
标签上的填充或边距。 / p>
原始问题的原始答案:
p,ul {
padding:0;
保证金:0;
}
这将占用任何多余的空白。
p,ul {
display:inline;
}
这将使所有元素内联而不是块。 (因此,例如< p>
不会在换行前后引起换行。)
<p>Text</p>
<ul>
<li>One</li>
</ul>
<p>Text 2</p>
How do i remove the vertical space between paragraph and the list.
To be more specific - how do I reduce the bottom margin/padding of the p tag ONLY when followed by an unordered list. All the answers I see here remove the space after all p tags - that's not what was asked.
You can use CSS selectors in a way similar to the following:
p + ul {
margin-top: -10px;
}
This could be helpful because p + ul
means select any <ul>
element after a <p>
element.
You'll have to adapt this to how much padding or margin you have on your <p>
tags generally.
Original answer to original question:
p, ul {
padding: 0;
margin: 0;
}
That will take any EXTRA white space away.
p, ul {
display: inline;
}
That will make all the elements inline instead of blocks. (So, for instance, the <p>
won't cause a line break before and after it.)
这篇关于删除段落和无序列表之间的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!