测试 absolute 元素相对位置
by redky
HTML
<div class="box">
<div class="ab"></div>
</div>
CSS
.box {
background: #eee;
padding: 50px;
width: 200px;
height: 100px;
position: relative;
border: 10px inset #455;
}
.ab {
position: absolute; /* absolute 是相对于 relative 元素. 并且从 padding 位置开始的 */
top: 10px;
left: 10px;
background-color: red;
height: 50px;
width: 50px;
}