[英]Html e-mail template - Outlook ignore width of elements
I wanted to ask, how i can force Outlook to respect widths of elements? 我想问一下,如何强制Outlook尊重元素的宽度?
For example i have some piece of code inside table: 例如,我在表中有一些代码:
<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;"> </div>
</div>
</td>
</tr>
divider class has width 40px, but in outlook, div has 100% width, why ? 分隔线类的宽度为40px,但在Outlook中,div的宽度为100%,为什么?
HTML for email tends to rely purely on tables, so you're not going to be able to have divs
within a td
. 电子邮件的HTML倾向于纯粹依赖于表格,因此您将无法在td
使用divs
。
You'll then need to specify cell widths using both the raw width
attribute and inline css: 然后,您需要使用raw width
属性和内联css来指定单元格宽度:
<td width="40" style="width: 40px;">Cell content</td>
To be really safe you can go further and include a transparent 1x1 pixel image, which you can then use to force the width of cells. 为了真正安全起见,您可以走得更远,并包括一个透明的1x1像素图像,然后将其用于强制像元宽度。 For example: 例如:
<td width="40" style="width: 40px">
<img src="blank.gif" width="40" style="width: 40px;" />
</td>
I would recommend reading Campaign Monitor's guidelines on HTML for email. 我建议阅读电子邮件中有关HTML的Campaign Monitor指南 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.