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