为什么Firefox不使用空tbody渲染表的边框?

zer*_*per 7 css firefox border

当表具有空tbody时,Firefox无法正确呈现表格单元格边框.

但是如果你使用伪选择器 tbody:empty {display:none;}隐藏tbody元素,则所有内容都按预期呈现.

的jsfiddle

table {
    border-collapse: collapse;
}
th,
td {
    border: 1px solid #000;
}

.fixed tbody:empty {
    display: none;
}
Run Code Online (Sandbox Code Playgroud)
<table class="broken">
    <thead>
        <tr>
            <th>1</th>
            <td>2</td>
            <td>3</td>
        </tr>
    </thead>
    <tbody></tbody>
    <tfoot>
        <tr>
            <th>1</th>
            <td>2</td>
            <td>3</td>
        </tr>
    </tfoot>
</table>

<hr />

<table class="fixed">
    <thead>
        <tr>
            <th>1</th>
            <td>2</td>
            <td>3</td>
        </tr>
    </thead>
    <tbody></tbody>
    <tfoot>
        <tr>
            <th>1</th>
            <td>2</td>
            <td>3</td>
        </tr>
    </tfoot>
</table>
Run Code Online (Sandbox Code Playgroud)

Sti*_*ers 8

它很可能属于Firefox上的Bug 409254Bug 217769.

附注:虽然tbody空格在HTML 5中有效,但每个行组中的单元格数应colspan在一个表中匹配(使用除外).

解决方法是在表格和单元格元素上单独绘制边框.

table {
    border-collapse: separate; /*changed from collapse*/
    border-spacing: 0;
    border: 1px solid;
    border-width: 0 0 1px 1px; /*draw bottom and left borders*/
}
th,
td {
    border: 1px solid;
    border-width: 1px 1px 0 0; /*draw top and right borders*/
}
Run Code Online (Sandbox Code Playgroud)

的jsfiddle