<style> body {margin: 30px; font-size:9pt;}
.a, .b, .c, .d, .e { width: 100px; height: 100px; margin: 5 auto; color: #fff; background: #000; } .aa, .bb, .cc, .dd, .ee { top: 10px; left: 10px; width: 10px; height: 10px; overflow: hidden; background: #F90; } .b, .d, .e {position: relative;} .cc, .dd, .ee {position: absolute;} </style>
<div class="a"> <div class="aa"></div> A:均不设置postion,一般嵌套关系 </div>
<div class="b"> <div class="bb"></div> B:仅外div设置relative,一般嵌套关系 </div>
<div class="c"> <div class="cc"></div> C:仅内div设置absolute,文档中为嵌套关系,页面中内div浮起[非float],相对于页面定位,与外div无关。 </div>
<style> body {margin: 30px; font-size:9pt;}
.a, .b, .c, .d, .e { width: 100px; height: 100px; margin: 5 auto; color: #fff; background: #000; } .aa, .bb, .cc, .dd, .ee { top: 10px; left: 10px; width: 10px; height: 10px; overflow: hidden; background: #F90; } .b, .d, .e {position: relative;} .cc, .dd, .ee {position: absolute;} </style>
<div class="a"> <div class="aa"></div> A:均不设置postion,一般嵌套关系 </div>
<div class="b"> <div class="bb"></div> B:仅外div设置relative,一般嵌套关系 </div>
<div class="c"> <div class="cc"></div> C:仅内div设置absolute,文档中为嵌套关系,页面中内div浮起[非float],相对于页面定位,与外div无关。 </div>
<div class="d" style="background:#ff0000"> <div class="dd" ></div> D:外div设置relative,内div设置absolute,内div浮起来并相对于外div定位 </div>
<div class="d" style="background:#ff0000"> <div class="dd" style="position:relative"></div> D:外div设置relative,内div设置relative,内div浮起来并相对于外div定位 </div>
<div class="e"> <div class="ee" style="left: -10px;"></div> E:这个是说明边界问题。-10 != 反向10px间距 </div>
|