0

我在 td 中有一个 div,我似乎无法删除它周围的 1 px 边框。如果我尝试添加td {padding:0},边框会消失,但 div 会跳到左侧,变量 td 会自动更改为 0px 宽度。如何在不弄乱整个表格的情况下删除 div 周围的边框?

HTML:

<table>
    <tr>
        <td class="header-left"></td>
        <td class="header">
            <div class="header-image"></div>
        </td>
        <td class="header-right"></td>
    </tr>
</table>

CSS:

table {
width:100%;
border-spacing: 0;
}

.header-left {
height:100px;
background-image:url(img/header-left.png);
background-repeat:repeat-x;

}

.header-right {
height:100px;
background-image:url(img/header.png);
background-repeat:repeat-x;
}

.header {
height:100px;
width:960px;
background-image:url(img/header.png);
background-repeat:repeat-x;
margin:0 auto;
}

.header-image {
height:100px;
width:548px;
background-repeat:no-repeat;
background-image:url(img/header-image.png);
}
4

4 回答 4

0
<table cellspacing="0" cellpadding="0" border="0"></table>

这样,您在表格中创建的 td 周围不会有任何间距。

于 2013-02-25T15:44:31.417 回答
0

尝试:

Border:none 在类头或创建类全局表 {border-collapse:collapse; 边框间距:0;边框:0;}

于 2013-06-06T15:31:15.090 回答
0

您只需设置表的属性,如下所示

<table cellpadding="0" cellspacing="0" border="0">

在css更改中尝试以下

table { border:none;}

如果仍然没有得到解决方案,请给我一个在 div 周围有边框的例子,因为在这里我看不到 div 周围的任何边框

于 2013-03-28T11:38:54.260 回答
0

在 DIV 标记中添加以下代码

<DIV class ="header-image" style="border:0px">  

或者如果您对表格边框有疑问,请设置 table border=0

于 2013-02-25T15:48:56.010 回答