简体   繁体   English

Outlook 中的 HTML email 显示错误

[英]Wrong display of HTML email in Outlook

I have the following code for an HTML email:对于 HTML email,我有以下代码:

<div style="background-color:red;max-width:600px;height:140px;margin-left:auto;margin-right:auto;">

<img src="https://via.placeholder.com/140x99" height="140" width="99" style="height:140px;width:99px;display:block;border:0;float:right;margin:0px;padding:0px;">

<p style="margin:0;font-size:30px;font-weight:700;padding-left:10px;margin-top:0px;padding-top:10px;">This is an important example header!</p>

</div>

I expect the HTML to get rendered like this:我希望 HTML 呈现如下:

在此处输入图像描述

The text is on the left side, the image is on the right side and has the same height as the red parent element.文本在左侧,图像在右侧,并且与红色父元素具有相同的高度。

I tested this with all 86 e-mail renderers of Email On Acid .我用Email On Acid的所有 86 个电子邮件渲染器对此进行了测试。 The HTML code gets rendered correctly on almost all email clients. HTML 代码几乎可以在所有 email 客户端上正确呈现。

But there's a wrong display on the following e-mail clients:但以下电子邮件客户端显示错误:

Outlook Office 356 (Windows 10)
Outlook 2007 (Windows 7)
Outlook 2010 (Windows 7)
Outlook 2013 (Windows 7)
Outlook 2016 (Windows 10)
Outlook 2019 (Windows 10)

I get the following output:我得到以下 output:

在此处输入图像描述

You see, the image is on the left side and the text is below the image.您会看到,图像在左侧,文本在图像下方。

What can I do to make the output right also on Outlook email clients?我该怎么做才能使 output 也在 Outlook email 客户端上正确?

Apply align="right" on image.在图像上应用align="right"

Note: I am not 100% sure if it'll work, since I don't have access to Email on Acid at the moment.注意:我不能 100% 确定它是否会起作用,因为我目前无法访问 Acid 上的 Email。

<div style="background-color:red;max-width:600px;height:140px;margin-left:auto;margin-right:auto;">

<img src="https://via.placeholder.com/140x99" align="right" height="140" width="99"
style="height:140px;width:99px;display:block;border:0;float:right;margin:0px;padding:0px;">

<p style="margin:0;font-size:30px;font-weight:700;padding-left:10px;margin-top:0px;padding-top:10px;">This is an important example header!</p>

</div>

I finally ended up with this code, that is working also on Outlook:我终于得到了这段代码,它也适用于 Outlook:

<center>

<!--[if !mso]><!-->
<table style="background-color:red;max-width:600px;height:140px;margin-left:auto;margin-right:auto;border-spacing:0px;">
<!--<![endif]-->
<!--[if mso]>
<table style="background-color:red;width:600px;height:140px;margin-left:auto;margin-right:auto;border-spacing:0px;align:center;">
<![endif]-->

<tbody>
<tr>
<td style="margin:0;font-size:30px;font-weight:700;padding-left:10px;width:100%;">This is an important example header!</td>
<td style="margin:0px;padding:0px;"><img src="https://via.placeholder.com/140x99" height="140" width="99" style="height:140px;width:99px;border:0;margin:0px;padding:0px;display:block;"></td>
</tr>
</tbody>
</table>

</center>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM