发现overflow:hidden 有clear:both 的功效
当父容器设置了 overflow:hidden 的时候
发现效果 等效于设置了父容器的清除浮动伪类 :after clear:both
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="gbk">
<style type="text/css">
.wyFirst {
width: 100px;
height: 100px;
background-color: red;
float: left;
}
.wySecond {
width: 100px;
height: 100px;
background-color: blue;
float: left;
}
.wrapper {
background-color: yellow;
overflow:hidden;// 这一句与下面after 等效
}
.wrapper:after {
clear: both;
display: block;
content: " ";
}
.wyThird {
width: 100px;
height: 100px;
background-color: green;
float: left;
}
</style>
</head>
<body>
<div>
<div class="wrapper">
<div class="wyFirst">this is a test</div>
<div class="wySecond">this is a float</div>
</div>
<div class="wyThird">this is a float</div>
</div>
</body>
</html>