<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.box1{
/* background-color: chocolate; */
border: darkkhaki 10px solid;
}
.box2{
width: 100px;
height: 200px;
background-color: crimson;
float: left;
}
/* .box3{ */
/*
/* width: 100px;
height: 300px; */
/* clear: both;
} */
/* 利用伪元素的方法完美解决相邻元素外边距重叠问题和高度塌陷问题*/
.clearfix::before,
.clearfix::after{
content: "";
display: table;
clear: both;
}
</style>
</head>
<body>
<div class="box1 clearfix">
<div class="box2 ">
</div>
<!-- <div class='box3'></div> -->
<!-- </div> -->
</div>
</body>
</html>