html - 在 Firefox 和 border-collapse : collapse; 中不存在单元格的表上隐藏边框

标签 html css firefox

给定以下 HTML 页面,表格顶部出现一条水平线,其中第一行将包含第二和第三个单元格(如果已定义)。

<html>
<head>
<Title>Test Page</Title>

<style type="text/css">
table {
    margin:10px 0 10px 0;
    padding:0;
    margin: 0 0 0 0;
    border-collapse: collapse;
    border: 0;
}

td {
    border:1px solid #CCCCCC;
    padding:5px;
}
</style>

</head>
<body>
    <table>
        <tr>
            <td>Test Title</td>
        </tr>
        <tr>
            <td>Sub Title</td>
            <td>Sub Title</td>
            <td>Sub Title</td>
        </tr>
    <table>
</body>
</html>

我希望仅通过修改 CSS 来删除该行(在下面突出显示)。此行出现在 Firefox 而不是 IE6。

Example Image

请注意,我不能以任何方式修改 HTML,因为这是由第三方系统生成的(上面的示例只是为了突出问题)。这个第三方系统只允许我修改CSS。

最佳答案

这将使它在 Firefox 中呈现时没有顶部边框:

table, td {
    border: 1px #CCC;
}

table {
    margin: 0;
    border-spacing: 0;
    border-style: none none solid solid;
}

* html table {
    border-collapse: collapse;
}

td {
    border-style: solid solid none none;
    padding: 5px;
}

它在 IE7 中也能正常工作。如果它在 IE6 中中断,请使用条件注释或 css hack 将其恢复到您自己的代码中仅适用于 IE6 的状态。

关于html - 在 Firefox 和 border-collapse : collapse; 中不存在单元格的表上隐藏边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/595253/

相关文章:

css - 使用可折叠部分组织 CSS...?

html - 响应式网站中的滚动问题

html - 如何使用嵌套的可折叠菜单?

javascript - 如何将缩略图添加到提及当前幻灯片的光滑 slider 的点

javascript - 现场验证无法正常工作

html - 如何防止 float div 不扩展 sibling

html - 文本的垂直对齐 - Bootstrap

javascript - 图像映射适用于 Internet Explorer,但不适用于 Chrome

firefox - 开发网页的最佳屏幕分辨率是多少?

javascript - -moz-win-borderless-glass 有效吗?