3

我研究了这个问题,在网上找到了许多建议的修复方法,但没有任何效果。

问题是我正在设计的 HTML 电子邮件中表格中特定 TD 元素之间的差距。它仅在 Outlook 2007 和 2010 中以这种方式显示。

这是问题的屏幕截图的链接

在右侧的侧边栏中,“Level 2”与其上方的薄圆角框之间应该没有间隙。

这是创建蓝色框的嵌套表的代码:

<table class="box" width="200" border="0" cellspacing="0" cellpadding="0"><tr><td style='line-height:0;font-size:0'><img src="http://dl.dropbox.com/u/16792732/wave-email-images/box_dark_top.gif" style="display:block" width="200" height="10" /></td></tr><tr><td class="box_dark"><h2>Level 2<br /><span class="white">Care Assistants</span></h2><h2>Level 3<br /><span class="white">Senior Carers</span></h2><h2 class="norule">Level 5<br /><span class="white">Managers and Deputy Managers</span></h2></td></tr><tr><td style='line-height:0'><img src="http://dl.dropbox.com/u/16792732/wave-email-images/box_dark_bottom.gif" style="display:block" width="200" height="10" /></td></tr></table>

如您所见,我已经删除了所有空白,因为这是我发现的一种解决方法中所建议的。我还在 TD 元素中插入了 'line-height:0;font-size:0' 样式,并在图像本身中插入了 'display:block' 样式,这也是所有建议的解决方法。这些都没有丝毫不同。

此问题不会出现在任何其他电子邮件客户端或浏览器中。

请帮忙!

4

4 回答 4

10

使用表格是 html 电子邮件构建中的标准做法,因为电子邮件客户端(尤其是 Outlook)中的 css 支持很差。

保留您的表结构,但尝试以下添加:

  • 添加valign="bottom"到包含 box_dark_top.gif 的 td 单元格和valign="top"接下来的两个单元格
  • 对于每个图像,将 css 设置为style="display:block;margin:0;padding:0"
  • 使用内联 CSS 而不是内部

    <table class="box" width="200" border="0" cellspacing="0" cellpadding="0">
    <tr><td valign="bottom"><img src="http://dl.dropbox.com/u/16792732/wave-email-images/box_dark_top.gif" style="display:block;margin:0;padding:0" width="200" height="10" alt="" /></td></tr>
    <tr>
        <td valign="top" class="box_dark">
            <h2>Level 2<br /><span class="white">Care Assistants</span></h2>
            <h2>Level 3<br /><span class="white">Senior Carers</span></h2>
            <h2 class="norule">Level 5<br /><span class="white">Managers and Deputy Managers</span></h2>
        </td>
    </tr>
    <tr><td valign="top"><img src="http://dl.dropbox.com/u/16792732/wave-email-images/box_dark_bottom.gif" style="display:block;margin:0;padding:0" width="200" height="10" alt="" /></td></tr></table>
    
于 2011-08-10T07:41:38.907 回答
1

Outlook 2007 onward uses Word to render HTML. Here's an article about this, with links to more strongly-opinionated articles and websites.

Maybe you could try designing your message in Word (or Outlook itself)? Of course then it may not render properly in a sane email client.

于 2011-08-05T03:02:07.050 回答
0

设置 TD 的高度以及任何其他应该具有固定高度的 TD:

<td valign="bottom" height="10" width="200">

*您还应该在电子邮件中的所有 TD 上使用宽度。

于 2011-09-12T18:47:33.417 回答
0

我发现 Outlook 会在他们“感觉”喜欢的时候用 img 标签包装并设置 margin-top 样式。您可以检查通过将电子邮件另存为 html 生成的 html。

于 2012-06-01T10:17:49.140 回答