【发布时间】:2016-05-11 15:22:29
【问题描述】:
我有一个 HTML 表格,其中包含一个具有行跨度的单元格。基本上只是左边的一个单元格,右边有 rowspan=2 和 2 列。我希望右侧的列粘在顶部。但是,右侧的空间在两列之间平均分配。将 height: 100% 添加到右侧的最后一列在 Chrome 中可以解决问题,但在 FF 或 IE 中不起作用。
<table border="1" style="width: 200px;">
<tr>
<th>Col1</th>
<th>Col2</th>
</tr>
<tr>
<td rowspan="2">Some long cell here...The point is that the Col_A and Col_B should both stick to the top. I tried adding height: 100% to the last column (Col_B) but that does only work in Chrome. Firefox puts Col_B at the very bottom while IE seems to completely ignore it.</td>
<td>Col_A</td>
</tr>
<tr>
<td>Col_B</td>
</tr>
</table>
小提琴:https://jsfiddle.net/jtr1r132/1/
更新:
正如 Pragnest 在下面建议的那样,将 height:1px 添加到右侧的第一列 (Col_A) 对 Chrome 和 FF 有效。但在 IE(和 Edge)中,它仍然无法按预期工作。
【问题讨论】:
-
你想把示例 2 中的 Col_B 放在 ff 的顶部,对吧?
-
我认为你想用 height:100% 解决这个问题,这是 FF 中的问题,但如果你想要解决方案将 td 放在首位,那么在你的问题中提及,否则它将是动态问题。谢谢
-
如果可能的话,我希望 Col_B 在每个浏览器中都位于顶部 ;-)