<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>测试</title>
<style type="text/css">
*{
font-family: 微软雅黑;
margin: 0px;
}
.d1{
width: 500px;
height: 300px;
background: #f00;
position: absolute;
left: 50%;
top: 50%;
margin-left: -250px;
margin-top: -150px;
}
.d2{
width: 200px;
height: 100px;
background: #0f0;
position: relative;
left: 50%;
top: 50%;
margin-left: -100px;
margin-top: -50px;
}
</style>
</head>
<body>
<div class="d1">
<div class="d2"></div>
</div>
</body>
</html>