2013-02-25 50 views
0

我有一个TD内的div,我似乎无法删除它周围的1px边框。 如果我尝试添加td {padding:0},边框消失,但div跳到左侧,变量td自动变为0px宽度。 我怎样才能删除边框周围的边框而不搞乱整个桌子?td内的Div具有1 px边框。它如何被删除?

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); 
} 
+0

你能分享一个小提琴的例子吗? – Pandian 2013-02-25 15:52:08

回答

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

这样就不会有你的表内创建一个围绕TD的任何间隔。

+0

嗨。这个解决方案似乎与我的td {padding:0}尝试有相同的问题。 div周围的边框消失,但div跳到左侧。 .header-left和.header-right的宽度为0,而.header的宽度为1903(屏幕宽度)。 – 2013-02-25 16:08:33

+0

为了得到正确的标题,我们可以应用float:right;到标题图像。 但你能告诉我你想创建什么吗?因为现在,我摆脱了你的边界。而您的图片位于标题的右侧。 – Roy 2013-02-25 22:44:17

0

添加以下代码div标签

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

,或者如果你有问题,表格边框然后设置table border=0

+0

你可以看到现在的代码 – 2013-02-25 15:57:55

+0

如果我的答案帮助你不要把它标记为正确和投票给我。我会在那里对你有任何疑问 – 2013-02-25 16:00:05

+0

我尝试了两种变体,但他们不工作。该div仍然有一个边界。表中的其他元素看起来很好。 – 2013-02-25 16:04:16

0

你只是需要设置表格的属性,像下面

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

在css更改下面试试

table { border:none;} 

如果仍然没得到解决方案给我的例子,有大约格边界,因为在这里我看不到周围的div任何边界

0

尝试:

边界:无类头 或 科瑞级的全球 表{边界崩溃:崩溃; border-spacing:0; border:0; }