我使用这个问题作为指导Javascript work-around for display: table-cell in IE <= 7但是,我需要考虑rowspans,所以我可以在IE 7,8,9正确处理这个HTML。jQuery的无表布局与rowspans
<div class="Table">
<div class="Row">
<div class="RowSpan">
This column should equal the height (no fixed-height allowed) of the 2 rows sitting to the right.
</div>
<div class="SubRow">
<div class="Column">
Here is some sample text1.1. And some additional sample text.
</div>
<div class="Column">
Here is some sample text2.1. And some additional sample text.
</div>
</div>
<div class="SubRow">
<div class="Column">
Here is some sample text1.2. And some additional sample text.
</div>
<div class="Column">
Here is some sample text2.2. And some additional sample text.
</div>
</div>
</div>
<div class="Row">
<div class="RowSpan">
This column should equal the height (no fixed-height allowed) of the 2 rows sitting to the right.
</div>
<div class="SubRow">
<div class="Column">
Here is some sample text1.1. And some additional sample text.
</div>
<div class="Column">
Here is some sample text2.1. And some additional sample text.
</div>
</div>
<div class="SubRow">
<div class="Column">
Here is some sample text1.2. And some additional sample text.
</div>
<div class="Column">
Here is some sample text2.2. And some additional sample text.
</div>
</div>
</div>
</div>
的CSS
<style>
.Table{
display: table; width:300px; border: 1px solid black; border-spacing: 2px;
}
.Row{
display: table-cell; border: 1px solid black; vertical-align: middle; float: left;
}
.RowSpan{
display: table-cell; border: 1px solid black; vertical-align: middle;
}
.SubRow{
display: table-cell; width: 100px;
}
.Column{
border: 1px solid black;margin: 2px;
}
</style>
我找一个jQuery修复程序下面列出的脚本。这不是表格数据,所以我不想使用表格。
$('<table><tr><td></td><td></td><td></td></tr></table>')
.find('td')
.eq(0)
.append($('.Row'))
.end()
.eq(1)
.append($('.RowSpan'))
.end()
.eq(2)
.append($('.SubRow'))
.end()
.eq(3)
.append($('.Column'))
.end()
.end()
.appendTo($('.Table'));
如果它应该看起来像一个表,使用表。以任何其他方式做它是一个坏主意,浪费时间。 – Jon 2012-03-06 23:26:33
'if($。browser.msie)' - 当它在某些版本中受支持时出现问题,测试功能支持,查看modernizer – charlietfl 2012-03-06 23:40:37
@jon它不是表格数据,所以我不想使用表格 – 2012-03-06 23:42:17