<!DOCTYPE html>
<html lang="cn">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
/* 方法一 表格 */
/* .box {
display: table;
width: 200px;
height: 200px;
background: yellow;
}
.box>div{
background: red;
display: table-cell;
vertical-align: middle;
text-align: center;
} */
/* 方法二 transform */
/* .box {
position: relative;
width: 200px;
height: 200px;
background: yellow;
}
.box>div{
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background: red;
} */
/* 方法三 flex */
.box {
display: flex;
width: 200px;
height: 200px;
background: yellow;
align-items: center;
justify-content: center;
}
.box>div{
background: red;
}
</style>
</head>
<body>
<div class="box">
<div>hello world-1</div>
</div>
</body>
</html>