HTML邮件含图片的表格行之间出现线条,Gmail/Yahoo端显示异常
修复方案
- 删除冗余空行标签,你代码中
<tbody>下第一组<tr></tr>为空无内容,Gmail/Yahoo会将其解析为带有默认高度的行,直接删除即可。 - 统一给所有
table、tr、td元素添加line-height: 0内联样式,覆盖邮件客户端的默认行高规则,避免行高撑出间隙。 - 优化占位td的实现,原本用
占位的420px宽度td,直接删除内部的span和 ,给td设置和相邻图片等高的高度、匹配页面背景色即可,避免空格字符解析出额外高度。 - 给所有img标签补充
line-height: 0; outline: none属性,进一步避免图片周边出现额外间隙。
修改后完整代码
<body> <center> <table cellspacing="0" cellpadding="0" width="100%" style="border-collapse:collapse;border-style:none;margin:auto;max-width:640px;line-height:0;"> <tbody> <tr style="border:0;margin:0;padding:0;"> <td valign="top" width="100%" style="line-height:0;"> <table cellspacing="0" cellpadding="0" width="100%" style="border-spacing:0;border-collapse:collapse;border-style:none;margin:auto;max-width:640px;font-size:0em;line-height:0;"> <tbody> <tr style="border:0;margin:0;padding:0;"> <td valign="top" colspan="2" style="font-size: 0px;line-height:0;"> <div> <img src="https://tmmcscdn.azureedge.net/RdXp8J5xGyF483sTwWagA/Banner.jpg" style="margin: 0; border: 0; padding: 0; display: block;line-height:0;outline:none;" height="150" width="640"> </div> </td> </tr> <tr style="border:0;margin:0;padding:0;"> <td valign="top" width="420" style="font-size: 0px;line-height:0;height:32px;background-color:#ffffff;"> </td> <td valign="top" width="220" style="font-size: 0px;line-height:0;"> <div> <img src="https://tmmcscdn.azureedge.net/RdXp8J5xGyF483sTwWagA/ProfLiability_NSO.png" width="220" height="32" style="margin: 0; border: 0; padding: 0; display: block;line-height:0;outline:none;"> </div> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </center> </body>
内容的提问来源于stack exchange,提问作者logan
相关产品推荐
相关产品推荐

