<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>外边距margin</title>
<style>
#box1{
width: 300px;
height: 300px;
border: 1px solid red;
margin-bottom: 70px;
}
#box2{
width: 300px;
height: 300px;
border: 1px solid red;
margin-top: 50px;
}
#box3{
width: 300px;
height: 300px;
border: 1px solid red;
}
#box4{
width: 200px;
height: 200px;
border: 1px solid red;
margin-top: 50px;
}
#box5{
width: 200px;
height: 200px;
background: #000;
/*margin: auto;*/
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body>
<!-- 同级塌陷-->
<!--以最大的外边距为准-->
<div id="box1"></div>
<div id="box2"></div>
<!--嵌套传递-->
---------------------------------
<div id="box3">
<div id="box4"></div>
</div>
<!--自动挤压-->
<div id="box5"></div>
</body>
</html>