雾观远山

博客园 首页 新随笔 联系 订阅 管理

<!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>

posted on 2021-11-07 16:43  雾观远山  阅读(57)  评论(0)    收藏  举报