2013-02-25 40 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; }