演示代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="reset.css"/>
<style type="text/css">
html,body{
height: 100%;
}
#box{
width: 50%;
height: 50%;
background-color: aqua;
/* 弹性盒子居中 */
display: flex;
justify-content: center;
align-items: center;
}
.wyzx{
width: 50%;
height: 50%;
background-color: #ff0000;
left: 50%;top: 50%;
}
</style>
</head>
<body>
<div id="box">
<div class="wyzx"></div>
</div>
</body>
</html>