2012-01-09 54 views
1

我使用表格,因爲我需要發送html電子郵件。 任何方式我的麻煩是這樣的:我有兩個圖像堆疊在一起。它們都是鏈接,意味着在標籤內。問題是在IE8中無法擺脫的兩幅圖像之間出現白色填充。 這是代碼:填充<a>表中的標籤

<table cellspacing="0" cellpadding="0">  
    <tr> 
     <td> 
      <a href="http://wwwXXXXXX.com/screening.php" border="0" style="padding:0;margin:0;line-height: 0px"> 
      <img src="http://www.XXXXXXX.com/emails/images/host.jpg" border="0" /> 
      </a> 
     </td> 
    </tr> 
    <tr> 
     <td> 
      <a href="mailto:[email protected]" border="0" style="padding:0;margin:0;line-height: 0px"> 
      <img src="http://www.XXXXXX.com/emails/images/bottom_all.jpg" border="0" /> 
      </a> 
     </td> 
    </tr> 
</table> 

的空間展示只有在那裏有一個標籤(嘗試過的圖像 - 沒問題)。最初的填充出現在Firefox和IE8中,而不是鉻。在firefox中加入'line-height'作品後,IE8依然沒有什麼好處......

有什麼想法嗎?

編輯:實際上,我發現這個問題不僅出現在表中,但只要你有IMG包裹在錨。像這樣:

<a href="http://wwwXXXXXX.com/screening.php" border="0" style="padding:0;margin:0;line- height: 0px"> 
<img src="http://www.XXXXXXX.com/emails/images/host.jpg" border="0" /> 
</a> 
<a href="http://wwwXXXXXX.com/screening.php" border="0" style="padding:0;margin:0;line-height: 0px"> 
<img src="http://www.XXXXXXX.com/emails/images/host.jpg" border="0" /> 
</a> 

回答

2

嘗試增加

vertical-align: top; 

你的IMG元素。

這可以防止IMG從嘗試與文本基線,這將永遠留出空間,下方字符伸對齊。

+0

感謝,這工作更好的答案! – 2012-01-09 12:07:54

0

也許IE8和Firefox對「a」標記具有默認邊距或填充。
試試看。像:

a {margin:0;padding:0;) 

我已經刪除了TR標籤和他們所有的內部元素之間的所有空間,它的工作

+0

我做到了已經。看在代碼 – 2012-01-09 11:48:07

+0

嘗試做同樣以​​標籤 – lvil 2012-01-09 11:50:03

+0

沒有,沒有工作 – 2012-01-09 11:57:15

0

你應該重置所有邊距&填充在你的CSS *{margin:0;padding:0;}它會讓你的生活更輕鬆。

1

嘗試刪除TAG之間的「空白區域」。收盤前一個標記後直接打開每個TAG:

<a href="... 
><img src="... 
/></a>