在CSS中,两个div之间如何添加换行符一直是让人头疼的问题。今天,我们来一起研究一下。 对于两个div之间添加换行符的问题,我们可以使用CSS中的“clear:both”属性。clear:both的...
在CSS中,两个div之间如何添加换行符一直是让人头疼的问题。今天,我们来一起研究一下。
对于两个div之间添加换行符的问题,我们可以使用CSS中的“clear:both”属性。clear:both的意思是强制让元素换行,并且避免与其之前的浮动元素重叠。
下面是一段展示“clear:both”属性的CSS代码:
p{
clear:both;
}<div class="first">
<p>First div</p>
</div>
<br>
<div class="second">
<p>Second div</p>
</div>.first{
float:left;
}
<br>
.second{
float:right;
clear:both;
}