【问题标题】:Background color of table showing through around <td> elements通过 <td> 元素显示的表格的背景颜色
【发布时间】:2016-04-14 15:06:28
【问题描述】:

我在一张桌子上有一张桌子。我已将表格背景颜色设置为白色。

内表的背景保持白色,而外表的所有其他单元格设置为浅灰色。

但是,外部表格的白色背景颜色显示为所有 &lt;td&gt; 单元格周围的边框,我无法弄清楚如何摆脱 - 所有灰色单元格都应该是无边框的。我尝试将所有元素的边框属性设置为无但没有成功。任何帮助将不胜感激。

这是jsfiddle

<style>
body{
    background-color: lightcyan;
}
.gems {
    margin:0 8px; 
    padding:0; 
}
.gems table{
    width:100%;
    background-color:white;
}
.gems td {
    padding:0px 1px; 
    margin:0;
}
.gems tr.filelist {
    margin:5px;
    background-color: lightgrey;
}
.gems tr.tools {
    background-color: lightgrey;
}

div.textarea  {
    background-color: white;
}

</style>
<body>
<div class="gems">
    <table>
    <tr class="filelist">
        <td>filelist</td>
        <td>filelist</td>
    </tr>
    <tr class="tools">
        <td>tools</td>
        <td>
        <div class="textarea">
        This is a table
            <table>
            <tr>
            <td>Cell 1</td>         
            <td>Cell 2</td>         
            <td>Cell 3</td>         
            </tr>
            </table>
            </div>
        </td>
    </tr>
    </table>
</div>

</body>

【问题讨论】:

    标签: css colors html-table


    【解决方案1】:
    <table cellspacing="0">
    

    将此属性添加到您的table 标记中。

    【讨论】:

    • 谢谢。很高兴就是这么简单。我使用 border-spacing: 0px; 将其保存在 css 中,并在其他地方使用它 - 但只是忘记了它。
    猜你喜欢
    • 2023-02-13
    • 2022-12-12
    • 1970-01-01
    • 1970-01-01
    • 2018-04-17
    • 2013-07-15
    • 1970-01-01
    • 1970-01-01
    • 2012-05-21
    相关资源
    最近更新 更多