<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>position</title>
</head>
<body>
<div style="width:500px; height:500px; background-color:#000000; position:relative;">
<div style="width:500px; height:100px; background-color:#FF0000; position:absolute;top:0;left:0" ></div>
<div style="width:500px; height:100px; background-color:#FF0000; margin-top:150px; "></div>
<div style="width:500px; height:100px; background-color:#FF0000; position:absolute; bottom:0; right:0;"></div>
</div>
</body>
</html>
--------------------------------------
| 上 |
|-------------------------------------
| 中 |
|-------------------------------------
| 下 |
--------------------------------------
想实现这样的效果,可是上面的代码跑出来的效果是 整个大的div往下挪动了150px,觉得很奇怪。
<div style="width:500px; height:100px; background-color:#FF0000; margin-top:150px; "></div>
换成绝对定位或者相对定位都可以解决该问题。
按照正常的思想中间那一层距离他的父层top150px,应该没问题的啊,求解释。