BFC,格式化上下文,防止父元素高度坍塌,文档流的丢失
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.div1{
width: 400px;
padding: 10px;
border: 1px solid slateblue;
overflow: hidden;
}
.floatLeft{
float: left;
width: 200px;
height: 50px;
background: salmon;
}
.div2{
background: slategray;
overflow: hidden;
}
</style>
</head>
<body>
<div class="div1">
<div class="floatLeft">
11111111
</div>
<div class="div2">
2222222
</div>
</div>
</body>
</html>