div实现水平垂直居中

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.divWrap{
500px;
height: 800px;
background: red;
margin: 20px auto;
position: relative;
}

.div{
position: absolute;
30%;
height: 30%;
margin: auto;
top: 0;
left: 0;
bottom: 0;
right: 0;
background: green;
}
</style>
</head>
<body>

<div class="divWrap">
<div class="div">

</div>
</div>
</body>
</html>

原文地址:https://www.cnblogs.com/liuerpeng/p/10170052.html