css - 如何修复IE8中的绝对定位?

标签 css internet-explorer-8 css-position

在我用过的所有浏览器中,除了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>

最佳答案

声明文档类型。我鼓励您使用 HTML5 文档类型:

<!DOCTYPE html>

关于css - 如何修复IE8中的绝对定位?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1360131/

相关文章:

html - 网格元素在必要时占用尽可能多的空间

javascript - 我的网站无法在 ie8 HTML 解析错误 KB927917 中显示结果

html - 只滚动内容div,其他的应该是固定的

html - 网站菜单悬停CSS IE8问题

html - 当我应用 HTML5 shiv 时,为什么我的 HTML5 标签没有在 IE8 中设置样式?

html - 当设置到位置 "fixed"时,Leftnav 缩小宽度

css - 绝对位置在 IE8 中无法正常工作

css - 如何在网格中的列间隙区域内绘制分隔线

jquery - asp.net 如何让两个 <ul> 面对面

Javascript-根据 URL 的最后一个字符串动态更改背景图像