<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#Da{
width: 800px;
height: 600px;
background: lightgrey;
position: relative;/*绝对定位*/
left: 20%;
top: 5%;
}
#Zhong{
position: absolute;/*添加相对定位*/
width: 600px;
height: 300px;
background: green;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
#xiaoyi{
position: absolute;/*添加相对定位*/
width: 200px;
height: 200px;
background: yellow;
top: 0;/*从上往下*/
bottom: 0;/*从下往上*/
left: 0;
margin: auto;
}
#xiaoer{
position: absolute;/*添加相对定位*/
width: 200px;
height: 200px;
background: lightyellow;
top: 0;/*从上往下*/
bottom: 0;/*从下往上*/
right: 0;
margin: auto;
}
</style>
</head>
<body>
<!--
四个盒子 大包住中 中 包住小
大盒子 居中
中盒子 居中
小盒子一号 居左
小盒子二号 居右
-->
<div id="Da">
<div id="Zhong">
<div id="xiaoyi"></div>
<div id="xiaoer"></div>
</div>
</div>
</body>
</html>
浙公网安备 33010602011771号