<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div {
width: 400px;
height: 600px;
background-color: red;
overflow: hidden;
}
.box1 {
width: 100px;
height: 100px;
background-color: #fff;
/* 250px:(父块height减子块height )除以2
auto:行自动居中(也可自行计算,和高计算相同 )*/
margin: 250px auto;
}
</style>
</head>
<body>
<!-- 父块 -->
<div>
<!-- 子块 -->
<div class="box1">
</div>
</div>
</body>
</html>
具体说明在代码注释内