<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<link rel="stylesheet" href="../css/style.css"/>
<title></title>
</head>
<body>
<div id="content">
<div><div>居中</div></div>
</div>
</body>
</html>
#content>div{
width: 500px;
height: 400px;
position: fixed;
top: 50%;
left: 50%;
}
#content>div>div{
background-color: red;
text-align: center;
line-height: 400px;
position: relative;
overflow: hidden;
top: -50%;
left: -50%;
}