使用 flex
<div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<style>
section{
display: flex;
justify-content: space-evenly;
align-items: center;
flex-wrap: wrap;
height: 400px;
width: 400px;
}
div{
width: 45%;
height: 45%;
border: 1px solid grey;
}
</style>
</head>
<body>
<section>
<div></div>
<div></div>
<div></div>
<div></div>
</section>
</body>
<style>
.h{
width: 700px;
height: 700px;
background-color: black;
padding: 25px;
}
.hu{
width: 700px;
height: 50px;
background-color: aqua;
}
.hu-t{
width: 700px;
height: 50px;
background-color: aqua;
margin-top: 25px;
}
.header{
height: 450px;
width: 700px;
margin-top: 25px;
background-color: wheat;
display: flex;
justify-content: space-evenly;
align-items: center;
flex-wrap: wrap;
}
div{
width: 45%;
height: 45%;
background-color: white;
}
.fa{
width: 700px;
height: 50px;
background-color: #F5DEB3;
margin-top: 50px;
}
</style>
</head>
<body>
<div class="h">
<div class="hu"></div>
<div class="hu-t"></div>
<div class="header">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div class="fa"></div>
</body>