absolute与float布局会使得高度宽度 塌陷,仅仅保留边框。relative不会塌陷
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="gbk">
<style type="text/css">
#content {
color: red;
height: 100px;
width: 100px;
border: 1px solid #000000;
}
.myClass1{
border: 1px solid red;
position: relative;
top: 10px;
}
.myClass2 {
border: 1px solid red;
position: absolute;
top: 20px;
}
.myClass3 {
float: left;
border: 1px solid gray;
}
</style>
</head>
<body>
<div id="content">
<div class="myClass1"></div>
<div class="myClass2"></div>
<div class="myClass3"></div>
</div>
</body>
</html>