css绝对定位代码

  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
.style1 { position:relative;
height:150px; width:150px;
border:1px solid #000;
background-color:#a2d39c;
}
.style2 { position:absolute;
left:30px; top:30px;
height:50px; width:50px;
border:1px solid black;
margin-bottom:10px;
background-color:#FF0000;}
.style3 { border:1px solid black;
height:50px; width:50px;
background-color:#00FF00;}
</style>
</head>

<body>
<div class="style1">
<div class="style2"> 一个</div>
<div class="style3">2个</div>
</div>
</body>
</html>

posted @ 2010-12-18 19:39  刘竹青  阅读(294)  评论(0编辑  收藏  举报