繁体   English   中英

HTML电子邮件模板-Outlook忽略元素的宽度

[英]Html e-mail template - Outlook ignore width of elements

我想问一下,如何强制Outlook尊重元素的宽度?

例如,我在表中有一些代码:

<tr>
        <td width="100px" style="text-align: center">
        <div style="Margin-left: 20px;Margin-right: 20px;">
  <div class="divider" style="font-size: 2px;line-height: 2px;Margin-left: auto;Margin-right: auto;width: 40px!important;background-color: #ccc;Margin-bottom: 20px;">&nbsp;</div>
</div>
    </td>
    </tr>

分隔线类的宽度为40px,但在Outlook中,div的宽度为100%,为什么?

电子邮件的HTML倾向于纯粹依赖于表格,因此您将无法在td使用divs

然后,您需要使用raw width属性和内联css来指定单元格宽度:

<td width="40" style="width: 40px;">Cell content</td>

为了真正安全起见,您可以走得更远,并包括一个透明的1x1像素图像,然后将其用于强制像元宽度。 例如:

<td width="40" style="width: 40px">
  <img src="blank.gif" width="40" style="width: 40px;" />
</td>

我建议阅读电子邮件中有关HTML的Campaign Monitor指南

暂无
暂无

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

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