【发布时间】:2015-08-19 15:01:32
【问题描述】:
我试图让几个 div 跨越其容器的整个高度(这是一个表格单元格并且具有可变高度)。我希望每个 div 都是其父级的 50%,并且我也希望它们彼此之上。我所做的是将顶部的绝对定位为 top: 0; bottom: 50%; 和底部的一个为 bottom: 0;最高:50%。这种方法在大多数浏览器上都可以正常工作,但在 IE9+ 上。
这是我在 Chrome、Firefox 和 Safari 上的布局(令人惊讶的是,IE8 也是如此)以及我在 IE9+ 上得到的布局:
由于某种原因,这两个绝对定位的 div 在 Internet Explorer 上重叠。
这是我的标记:
<div class="table">
<div class="cell">
Bacon ipsum dolor amet short ribs shankle cupim strip steak shank bresaola bacon. Corned beef tri-tip turkey boudin. Strip steak short ribs meatloaf bacon shank kielbasa prosciutto. Pork chop picanha drumstick kielbasa jerky shankle strip steak beef ribs tenderloin pig tail landjaeger turducken.
</div>
<div class="cell">
<div class="top">TOP DIV</div>
<div class="bottom">BOTTOM DIV</div>
</div>
</div>
这些是我的风格:
.table {
display: table;
background-color: #cbcbcb;
border-spacing: 10px;
}
.cell {
display: table-cell;
vertical-align: middle;
position: relative;
width: 70%;
&:first-of-type {
width: 30%;
}
}
.bottom,
.top {
box-sizing: border-box;
position: absolute;
background-color: #fff;
padding: 20px;
width: 100%;
}
.bottom {
bottom: 0;
top: 50%;
margin-top: 5px;
}
.top {
top: 0;
bottom: 50%;
margin-bottom: 5px;
}
这是一个可以玩的垃圾箱:http://jsbin.com/yifeqe/edit?html,css,output
有什么想法吗?
【问题讨论】:
标签: html css internet-explorer cross-browser