【发布时间】:2015-02-07 16:03:36
【问题描述】:
我需要动态构建一个表来保存一些数据。
我遵循了使用带有display: table、display: table-row 和display: table-cell 的div 的常用方法:
.tab {
display: table;
height:100%;
width: 200px;
}
.row {
height: 100%;
display: table-row;
}
.elem {
border: 1px solid black;
vertical-align: top;
display: table-cell;
height:100%;
background: blue;
}
.content {
height: 100%;
background: greenyellow;
}
<div class="tab">
<div class="row">
<div class="elem">
<div class="content">
Content
</div>
</div>
<div class="elem">
<div class="content">
Longer content that will need to wrap around eventually you know and don't you hate it when things don't end as you expect them octopus
</div>
</div>
</div>
</div>
在大多数浏览器中,我得到了预期的输出:
但是,在 IE8(可能还有更高版本,我没有测试更高版本)中,我得到以下信息:
在 "Content" 周围的 div 上设置的 height: 100% 被忽略。
根据CanIUse,IE8 应该提供对相关显示属性的全面支持。
我查看了许多关于 SO 的类似问题,但没有找到可行的解决方案:大多数解决方案要么依赖 Javascript(我希望避免这种情况),要么使用固定高度(同上),要么不起作用在 IE8 上。
【问题讨论】:
-
@Guilherme Nascimento:这不是一张真正的桌子。它只是看起来像一个。
-
@GuilhermeNascimento 该表将用于保存表格或半表格数据,您看到的是用于显示问题的示例文本。你完全没有抓住问题的重点。
-
试试这样:jsfiddle.net/8x347w73 并使用
p作为内容,同时看看这个,它可能对你有帮助:css-tricks.com/fluid-width-equal-height-列/ -
@BoltClock 正是出于这个原因,我将“table”放在引号中。
-
@Nit 我没有遗漏任何内容,只是在您的问题中不清楚您要达到的目标,我问这个问题只是为了确保我能够制定适当的答案。
标签: css internet-explorer css-tables