使用Internet Explorer在表格单元格中定位绝对

Bal*_*lix 7 html css internet-explorer css-position

我有一个表结构,我需要嵌套元素来获取表格单元格的所有大小.所以我把它设置为绝对并将其所有位置定义为0,它在FireFox和Chrome上工作得很好但在IE上却不行:(

这是标记:

<div class="table">
    <div class="cell">
      <figure class="illustration">My illustration</figure>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

.table {
    display: table;
    width: 400px;
}

.cell {
  position: relative;
    display: table-cell;
    height: 600px;
    background-color: grey;
}

.illustration {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: red;
    color: #fff;
}
Run Code Online (Sandbox Code Playgroud)

这是我的笔:http: //codepen.io/balix/pen/qEMwzj

如果你看到红色背景就可以了;)

IE的任何黑客攻击?

小智 5

我有同样的问题。如果有人仍在寻找解决方法,则需要在.cell内使用以下方法创建一个容器

.cell > div{
    height:100%;
    width:100%;
    position:relative;
}
Run Code Online (Sandbox Code Playgroud)


Ale*_*yan -3

这不是位置问题,只是你的身材高度为零。我只是简单地插入height: 300pxillustration类中,现在它在 IE 上运行良好:

.illustration {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: red;
    color: #fff;
    height: 300px;
}
Run Code Online (Sandbox Code Playgroud)

http://codepen.io/anon/pen/QwVRoE

在真实的代码中,标签内肯定会有一些图像,figure所以应该没有问题。