在我使用过的每个浏览器中,除了 ie8,绝对定位的元素可以根据最近的父元素进行相对定位。
下面的代码显示了一个表中的两个 div。顶部 div 具有 position: relative,但是,嵌套的、绝对定位的元素不尊重其边界(在 ie8 中,它位于页面底部而不是父 div 的底部)。
有人知道解决这个问题吗?
<style>
#top {
position: relative;
background-color: #ccc;
}
#position_me {
background-color: green;
position: absolute;
bottom: 0;
}
#bottom {
background-color: blue;
height: 100px;
}
</style>
<table>
<tr>
<td><div id="top"> Div with id="top"
<div id="position_me"> Div with id="position me" </div>
</div>
<div id="bottom"> Div with id="bottom"
<p>Lorem ipsum dolor sit amet.</p>
</div></td>
</tr>
</table>