【发布时间】:2015-11-06 14:26:38
【问题描述】:
以下文档在 Firefox 和 Chrome 上的呈现方式不同:
<!DOCTYPE html>
<html>
<head>
<title>Table rendering test</title>
<style>
table {
border-collapse: collapse;
border-spacing: 0;
padding: 0;
background-color: #ffffff;
border: 2px solid black;
}
table td {
border: 1px solid black;
padding: 5px;
}
tr.testRow > td {
border-left-width: 0;
border-right-width: 0;
padding: 0;
}
tr.testRow table {
border-color: #ff0000;
}
</style>
</head>
<body>
<table>
<tr>
<td>cell1.1</td>
<td>cell1.2</td>
<td>cell1.3</td>
</tr>
<tr class="testRow">
<td>cell2.1</td>
<td colspan="2">
<table>
<tr>
<td>internal table cell</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
请注意 Firefox 如何不将右下角单元格的边框作为其内容的一部分,因此“内部表格”会在上述单元格的边框右侧呈现 1 个像素。然而,Chrome 会在与上述单元格边框相同的水平位置呈现“内部表格”。
这两种浏览器都在标准模式下运行。哪个浏览器表现出正确的行为?以及如何修改代码以使它们都表现出 Chrome 给出的行为(这是我想要的)?
【问题讨论】:
标签: html css google-chrome firefox