段落边距超出了div

时间:2018-06-05 09:43:45

标签: html css margins

当段落嵌套在div中时,我总是遇到这个问题。段落的默认边距高于div,并向下推动父div。您可以检查由段落引起的div之间的空白区域。我不想消除段落的边距,但我希望边距放在父div中。

#div1{
background:#00ff00;
}

#div2{
background:#eeeeee;
}

p{
background:#ff8800;
}
<div id="div1">Top div with unwanted space below</div>
<div id="div2">
<p>The margins of this paragraph pushes the parent div downward</p>
</div>

0 个答案:

没有答案