1. 使用绝对定位与相对定位
2. table布局方式
3. flex布局(1)
4. flex布局(2)
5. transform
6. grid布局
<html>
<head>
<title>我的第一个 HTML 页面</title>
</head>
<body>
<div class="box">
<div class="box1"></div>
</div>
</body>
</html>
<style>
.box {
width: 300px;
height: 200px;
background: red;
display: flex;
}
.box1 {
width: 100px;
height: 50px;
background: yellow;
margin: auto;
}
</style>