Outlook 中 HTML 电子邮件的对齐问题
我在 Outlook 中正确呈现 HTML 电子邮件时遇到问题。上面的图片是它在 Gmail 中的样子。第二张图片由 Outlook 2016 渲染不正确。过去 2 天我一直被这个问题困扰。任何帮助都非常感激。
这是在 HTML 中呈现的代码:
<!-- COLUMN TITLE -->
<!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:740px;" width="740" bgcolor="#ffffff" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
<div style="background:#ffffff;background-color:#ffffff;margin:0px auto;max-width:740px;">
<table class="event-history-outlook" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ffffff;background-color:#ffffff;width:100%;">
<tbody>
<tr>
<td style="direction:ltr;font-size:0px;padding:0px 0;padding-bottom:7px;text-align:center;">
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:740px;" ><![endif]-->
<div class="column-per-33-333333333333336 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table class="event-history-outlook" border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="left" style="font-size:0px;padding:10px 25px;padding-right:25px;padding-bottom:0px;padding-left:20px;word-break:break-word;">
<div style="font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:12px;line-height:1;text-align:left;color:#9c9c9c;">DATE AND TIME</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td><td class="" style="vertical-align:top;width:740px;" ><![endif]-->
<div class="column-per-50 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table class="event-history-outlook" border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="left" style="font-size:0px;padding:10px 0 10px 0;padding-bottom:0px;word-break:break-word;">
<div style="font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:12px;line-height:1;text-align:left;color:#9c9c9c;">TITLE</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td><td class="" style="vertical-align:top;width:740px;" ><![endif]-->
<div class="column-per-16-66666666666666 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table class="event-history-outlook" border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="left" style="font-size:0px;padding:10px 0 10px 0;padding-bottom:0px;padding-left:10px;word-break:break-word;">
<div style="font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:12px;line-height:1;text-align:left;color:#9c9c9c;">CODE</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
</div>
<!-- END COLUMN TITLE -->
<!-- HORIZONTAL LINE -->
<div style="background:#ffffff;background-color:#ffffff;margin:0px auto;max-width:740px;">
<table class="event-history-outlook" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ffffff;background-color:#ffffff;width:100%;">
<tbody>
<tr>
<td style="direction:ltr;font-size:0px;padding:0px 0;padding-bottom:8px;text-align:center;">
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:740px;" ><![endif]-->
<div class="column-per-100 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table class="event-history-outlook" border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;padding-top:0;padding-right:20px;padding-bottom:0px;padding-left:20px;word-break:break-word;">
<p style="border-top:solid 1px #BBBBBB;font-size:1px;margin:0px auto;width:100%;">
</p>
<!--[if mso | IE]><table class="event-history-outlook" align="center" border="0" cellpadding="0" cellspacing="0" style="border-top:solid 1px #BBBBBB;font-size:1px;margin:0px auto;width:700px;" role="presentation" width="700px" ><tr><td style="height:0;line-height:0;">
</td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- END HORIZONTAL LINE -->
<!-- FAULT ROW -->
<!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:740px;" width="740" bgcolor="#ffffff" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
<div style="background:#ffffff;background-color:#ffffff;margin:0px auto;max-width:740px;">
<table class="event-history-outlook" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ffffff;background-color:#ffffff;width:100%;">
<tbody>
<tr>
<td style="direction:ltr;font-size:0px;padding:0px 0;padding-bottom:8px;text-align:center;">
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:740px;" ><![endif]-->
<div class="column-per-33-333333333333336 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table class="event-history-outlook" border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="left" style="font-size:0px;padding:10px 25px;padding-right:25px;padding-bottom:0px;padding-left:20px;word-break:break-word;">
<div style="text-decoration:none;font-family:Helvetica;font-size:12px;line-height:1;text-align:left;color:#528ecb;">[DATE_TIME]</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td><td class="" style="vertical-align:top;width:740px;" ><![endif]-->
<div class="column-per-50 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table class="event-history-outlook" border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="left" style="font-size:0px;padding:10px 0 10px 0;padding-bottom:0px;word-break:break-word;">
<div style="font-family:Helvetica;font-size:12px;line-height:1;text-align:left;color:#4a4a4a;">[TITLE]</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td><td class="" style="vertical-align:top;width:740px;" ><![endif]-->
<div class="column-per-16-66666666666666 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table class="event-history-outlook" border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="left" style="font-size:0px;padding:10px 0 10px 0;padding-bottom:0px;padding-left:10px;word-break:break-word;">
<div style="font-family:Helvetica;font-size:12px;line-height:1;text-align:left;color:#4a4a4a;">[CODE]</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
</div>
<!--END FAULT ROW -->
I'm having trouble rendering my HTML email correctly in Outlook. The top picture is how it is supposed to look like in Gmail. The second picture is being rendered incorrectly by Outlook 2016. I've been stuck on this issue for the past 2 days. Any helps is greatly appreciate it.
This is the code that is being rendered in HTML:
<!-- COLUMN TITLE -->
<!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:740px;" width="740" bgcolor="#ffffff" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
<div style="background:#ffffff;background-color:#ffffff;margin:0px auto;max-width:740px;">
<table class="event-history-outlook" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ffffff;background-color:#ffffff;width:100%;">
<tbody>
<tr>
<td style="direction:ltr;font-size:0px;padding:0px 0;padding-bottom:7px;text-align:center;">
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:740px;" ><![endif]-->
<div class="column-per-33-333333333333336 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table class="event-history-outlook" border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="left" style="font-size:0px;padding:10px 25px;padding-right:25px;padding-bottom:0px;padding-left:20px;word-break:break-word;">
<div style="font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:12px;line-height:1;text-align:left;color:#9c9c9c;">DATE AND TIME</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td><td class="" style="vertical-align:top;width:740px;" ><![endif]-->
<div class="column-per-50 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table class="event-history-outlook" border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="left" style="font-size:0px;padding:10px 0 10px 0;padding-bottom:0px;word-break:break-word;">
<div style="font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:12px;line-height:1;text-align:left;color:#9c9c9c;">TITLE</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td><td class="" style="vertical-align:top;width:740px;" ><![endif]-->
<div class="column-per-16-66666666666666 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table class="event-history-outlook" border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="left" style="font-size:0px;padding:10px 0 10px 0;padding-bottom:0px;padding-left:10px;word-break:break-word;">
<div style="font-family:Arial, Helvetica Neue, Helvetica, sans-serif;font-size:12px;line-height:1;text-align:left;color:#9c9c9c;">CODE</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
</div>
<!-- END COLUMN TITLE -->
<!-- HORIZONTAL LINE -->
<div style="background:#ffffff;background-color:#ffffff;margin:0px auto;max-width:740px;">
<table class="event-history-outlook" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ffffff;background-color:#ffffff;width:100%;">
<tbody>
<tr>
<td style="direction:ltr;font-size:0px;padding:0px 0;padding-bottom:8px;text-align:center;">
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:740px;" ><![endif]-->
<div class="column-per-100 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table class="event-history-outlook" border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;padding-top:0;padding-right:20px;padding-bottom:0px;padding-left:20px;word-break:break-word;">
<p style="border-top:solid 1px #BBBBBB;font-size:1px;margin:0px auto;width:100%;">
</p>
<!--[if mso | IE]><table class="event-history-outlook" align="center" border="0" cellpadding="0" cellspacing="0" style="border-top:solid 1px #BBBBBB;font-size:1px;margin:0px auto;width:700px;" role="presentation" width="700px" ><tr><td style="height:0;line-height:0;">
</td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- END HORIZONTAL LINE -->
<!-- FAULT ROW -->
<!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:740px;" width="740" bgcolor="#ffffff" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
<div style="background:#ffffff;background-color:#ffffff;margin:0px auto;max-width:740px;">
<table class="event-history-outlook" align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ffffff;background-color:#ffffff;width:100%;">
<tbody>
<tr>
<td style="direction:ltr;font-size:0px;padding:0px 0;padding-bottom:8px;text-align:center;">
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" style="vertical-align:top;width:740px;" ><![endif]-->
<div class="column-per-33-333333333333336 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table class="event-history-outlook" border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="left" style="font-size:0px;padding:10px 25px;padding-right:25px;padding-bottom:0px;padding-left:20px;word-break:break-word;">
<div style="text-decoration:none;font-family:Helvetica;font-size:12px;line-height:1;text-align:left;color:#528ecb;">[DATE_TIME]</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td><td class="" style="vertical-align:top;width:740px;" ><![endif]-->
<div class="column-per-50 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table class="event-history-outlook" border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="left" style="font-size:0px;padding:10px 0 10px 0;padding-bottom:0px;word-break:break-word;">
<div style="font-family:Helvetica;font-size:12px;line-height:1;text-align:left;color:#4a4a4a;">[TITLE]</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td><td class="" style="vertical-align:top;width:740px;" ><![endif]-->
<div class="column-per-16-66666666666666 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table class="event-history-outlook" border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
<tbody>
<tr>
<td align="left" style="font-size:0px;padding:10px 0 10px 0;padding-bottom:0px;padding-left:10px;word-break:break-word;">
<div style="font-family:Helvetica;font-size:12px;line-height:1;text-align:left;color:#4a4a4a;">[CODE]</div>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
</div>
<!--END FAULT ROW -->
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每个特定于 Outlook(如果是 mso)的表列都有“740px”。您需要将它们设置为 33%、50% 和 16%(但作为像素),Outlook 才能正常工作。
顺便说一句,您还应该内联不支持
块的其他电子邮件环境的宽度。例如,Gmail IMAP 不支持此功能。所以只需将 width:33% 放在内联而不是作为一个类。
这是新代码:
You've got "740px" for each of the Outlook-specific (if mso) table columns. You would need to make them 33%, 50% and 16% -- but as pixels -- for Outlook to work.
Incidentally, you should also inline the widths for other email environments that don't support
<style>
blocks. For example, Gmail IMAP doesn't support this. So just put the width:33% inline instead of as a class.Here's the new code: