清除div浮动的三种方式
html:
<body>
<div class="main">
<div class="first"></div>
<div class="second"></div>
</div>
</body>
<style>
.main
{
overflow:hidden;
border:1px solid black;
}
.first{
width:100px;
height:100px;
float:left;
background:#33ffff;
}
.second
{
float:left;
width:300px;
height:300px;
background:#9900ff;
}
.clear
{
clear:both;
}
</style>
1:将main父级div增加高度
2:增加<div class="clear"></div>
3:将父级div增加:overflow:hidden