html - HTML 电子邮件中的 Outlook 表格间距 - 没有常用的技巧

标签 html css email outlook

我有一个按钮,为了让它在 Outlook 2007/10 (!) 中工作,我必须将三个元素 - 左图像、中间文本、右图像 - 放在一个更大的表格内的它们自己的嵌套表格中。但是,这会导致 Outlook 2007/10 中经常被引用的问题,即表格之间存在间隙。

下面是按钮的代码。很明显,上面还有 html head body 等等。

我已经在 img 和类似的表格上尝试了显示属性、宽度、对齐、边框/填充/边距 = 0...我已经尝试了我可以在网上找到的所有解决方案,但没有任何解决方案!

感谢收到关于其他尝试的任何想法!!

注意:这在 Outlook 中全面发生,而不仅仅是其中一个。

<tr>
<td style="width: 15px; font-size: 15px;" valign="top">&#160;</td>
<td align="center" valign="middle">
<table align="center" cellpadding="0" cellspacing="0" height="40" width="243" border="0" style="margin: 0; font-family: 'HelveticaNeue-CondensedBold', 'Arial Narrow', Arial, Helvetica, sans-serif; font-size: 16px; text-align: center; color: #ffffff; height: 40px; mso-table-lspace:0pt; mso-table-rspace:0pt; display: block; background-color: #f2f2f2;" valign="middle">
<tbody valign="middle">
<tr height="40">
    <td height="40">
    <table align="left" border="0" cellpadding="0" cellspacing="0" height="40" width="22" style="margin: 0; border: 0; padding: 0; width: 22px; font-family: 'HelveticaNeue-CondensedBold', 'Arial Narrow', Arial, Helvetica, sans-serif; font-size: 16px; text-align: center; color: #ffffff; height: 40px; background-color: #f2f2f2; mso-table-lspace:0pt; mso-table-rspace:0pt; display: block;" valign="middle">
    <tbody>
    <tr>
        <td height="40" width="22" style="background-color: #f2f2f2;"><a href="#" style="border: 0; text-decoration: none; color: #ffffff;" target="_blank">
        <img align="right" height="40" src="ctaleftgrey.jpg" style="width: 22px; margin: 0; border: 0; padding: 0; text-decoration: none; height: 40px; display: block;" width="22" /></a></td>
    </tr>
    </tbody>
    </table>
    <table align="left" border="0" cellpadding="0" cellspacing="0" height="40" width="180" style="margin: 0; border: 0; padding: 0; font-family: 'HelveticaNeue-CondensedBold', 'Arial Narrow', Arial, Helvetica, sans-serif; font-size: 16px; text-align: center; color: #ffffff; height: 40px; background-color: #ec6608; mso-table-lspace:0pt; mso-table-rspace:0pt; display: block; border-left: 1px solid #ec6608;" valign="middle">
    <tbody>
    <tr style="background-color: #ec6608;">
        <td height="40" style="height: 40px; font-family: 'HelveticaNeue-CondensedBold', 'Arial Narrow', Arial, Helvetica, sans-serif; font-size: 16px; text-align: center; color: #ffffff; background-color: #ec6608; mso-line-height-rule: exactly; line-height: 16px;"><a href="#" style="text-decoration:none; color:#ffffff" target="_blank">Text goes here</a></td>
    </tr>
    </tbody>
    </table>
    <table align="left" border="0" cellpadding="0" cellspacing="0" height="40" width="36" style="margin: 0; border: 0; padding: 0; width: 36px; font-family: 'HelveticaNeue-CondensedBold', 'Arial Narrow', Arial, Helvetica, sans-serif; font-size: 16px; text-align: center; color: #ffffff; height: 40px; background-color: #f2f2f2; mso-table-lspace:0pt; mso-table-rspace:0pt; display: block;" valign="middle">
    <tbody>
    <tr>
        <td height="40" width="36" style="background-color: #f2f2f2;"><a href="#" target="_blank"><img align="right" height="40" src="ctarightgrey.jpg" style="width: 36px; margin: 0; border: 0; padding: 0; text-decoration: none; height: 40px; display: block;" width="36" /></a></td>
    </tr>
    </tbody>
    </table>
    </td>
</tr>
</tbody>
</table>
</td>
<td style="width: 15px; font-size: 15px;" valign="top">&#160;</td>

最佳答案

这个出乎意料的难!我发现部分问题是由外表上的 align="center"引起的,导致 Outlook 2003 和 Live Mail 中出现 3px 的间隙。如果您仍然需要它与中心对齐,我会将这段代码包装在另一个具有该属性的表中。为了解决剩下的问题,我删除了额外的表格并添加了对齐到您的 TD。我还添加了“border-collapse: collapse;”到你的 table 。您现在应该在桌面 Outlook 客户端中看到没有间距。

<table cellpadding="0" cellspacing="0" height="40" width="238" border="0" style="border-collapse: collapse; margin: 0; font-family: 'HelveticaNeue-CondensedBold', 'Arial Narrow', Arial, Helvetica, sans-serif; font-size: 16px; text-align: center; max-width:238px; color: #ffffff; width:238px;height: 40px; mso-table-lspace:0pt; mso-table-rspace:0pt; background-color: #f2f2f2;">
<tbody>
    <tr>
        <td height="40" width="22" align="left">
                    <p style="mso-table-lspace:0;mso-table-rspace:0;margin:0;">
                        <a href="#" style="border: 0; text-decoration: none; color: #ffffff;" target="_blank">
                            <img height="40" src="ctaleftgrey.jpg" style="width: 22px; margin: 0; border: 0; padding: 0; text-decoration: none; height: 40px;" width="22" />
                        </a>
                    </p>
        </td>
        <td height="40" width="180" align="left">
            <table border="0" cellpadding="0" cellspacing="0" height="40" width="180" style="border-collapse: collapse; margin: 0; border: 0; padding: 0; font-family: 'HelveticaNeue-CondensedBold', 'Arial Narrow', Arial, Helvetica, sans-serif; font-size: 16px; text-align: center; color: #ffffff; height: 40px; background-color: #ec6608; mso-table-lspace:0pt; mso-table-rspace:0pt; " valign="middle">
                <tbody>
                    <tr>
                        <td height="40" style="height: 40px; font-family: 'HelveticaNeue-CondensedBold', 'Arial Narrow', Arial, Helvetica, sans-serif; font-size: 16px; text-align: center; color: #ffffff; background-color: #ec6608; mso-line-height-rule: exactly; line-height: 16px;">
                            <p style="mso-table-lspace:0;mso-table-rspace:0;margin:0;">
                                <a href="#" style="text-decoration:none; color:#ffffff;border: 0px;" target="_blank">Text goes here</a>
                            </p>
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td height="40" width="36" align="left">
                    <p style="mso-table-lspace:0;mso-table-rspace:0;margin:0;">
                        <a href="#" target="_blank">
                            <img height="40" src="ctarightgrey.jpg" style="width: 36px; margin: 0; border: 0; padding: 0; text-decoration: none; height: 40px;" width="36" />
                        </a>
                    </p>
        </td>
    </tr>
</tbody>

关于html - HTML 电子邮件中的 Outlook 表格间距 - 没有常用的技巧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32071608/

相关文章:

html - 垂直更多虚线选项

html - 手机 <p> 和其他标签中的字体太大

html - 嵌套在 CSS 网格中

java - 如何使用 Java Mail API 检索任何电子邮件的电子邮件正文

java - 使用 Spring Boot 发出有关退回邮件的警报

html - 如何成功创建两列布局?一个用于左侧的垂直导航栏和右侧的内容

html - 将文本放在与第二行文本溢出省略号内联的点之后

javascript - 从 css 类动画显示/隐藏

web-services - IMAP 转发器

html - 从现有的非标记内容构建 HTML ID 属性