2013 年 8 月更新:我怀疑这对 John 仍然有用。 B,但我只是想为可能遇到此问题的任何人提供快速更新。
我能够解决我之前描述的问题,并阻止背景图像从纯色背景下方窥视。
这是更新后的代码:
<table background="http://i.imgur.com/n8Q6f.png" cellpadding="0" cellspacing="0" width="200">
<tr>
<td>
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width: 200px;">
<v:fill type="tile" src="http://i.imgur.com/n8Q6f.png" color="#f6f6f6" />
<v:textbox style="mso-fit-shape-to-text: true;" inset="0,0,0,0">
<![endif]-->
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100"></td>
<td bgcolor="#ffffff" width="100">
The<br/>
background<br/>
image<br/>
on<br/>
the<br/>
left<br/>
will<br/>
stretch<br/>
to<br/>
the<br/>
height<br/>
of<br/>
this<br/>
content.
</td>
</tr>
</table>
<!--[if gte mso 9]>
<p style="margin:0;mso-hide:all"><o:p xmlns:o="urn:schemas-microsoft-com:office:office"> </o:p></p>
</v:textbox>
</v:rect>
<![endif]-->
</td>
</tr>
</table>
这里的修复是行
<p style="margin:0;mso-hide:all"><o:p xmlns:o="urn:schemas-microsoft-com:office:office"> </o:p></p>
就在文本框结束之前,我已经解释了这个in the Microsoft Office TechCenter thread I referred to in a previous comment。
我原来的回答:
我已经能够几乎破解这个,但不完全。所以我在这里发布这个,希望有人可以在它的基础上发布一个完整的解决方案。
我很确定您无法获得背景图像来实际填充表格单元格或其他未定义高度的区域。但是,您可以使用 [VML TextBox][1] 和 [VML Fill Element][2] around 表格,定义背景图像和后备颜色,可以拉伸到内容。
然后,您可以在此文本框中放置一个包含两列的表格,其中一个具有透明背景,另一个具有纯色背景,以模拟您描述的布局。
在文本框周围,为非 Outlook 电子邮件客户端使用相同的背景图像和后备颜色环绕另一个表格。
现在,这一切都很好,但我遇到的问题是 Outlook/Word 渲染引擎坚持在文本框内的表格下方添加一个空白行。因此,虽然 Outlook 会在内容的一侧重复背景图像,但它也会在外部表格的整个宽度处添加一行背景图像。
在 Outlook 2007+ 中测试以下内容,看看我目前有什么:
<table background="http://i.imgur.com/n8Q6f.png" cellpadding="0" cellspacing="0" width="200">
<tr>
<td>
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width: 200px;">
<v:fill type="tile" src="http://i.imgur.com/n8Q6f.png" color="#f6f6f6" />
<v:textbox style="mso-fit-shape-to-text: true;" inset="0,0,0,0"><span style="font-size: 0px;">
<![endif]-->
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100"></td>
<td bgcolor="#ffffff" width="100">
The<br/>
background<br/>
image<br/>
on<br/>
the<br/>
left<br/>
will<br/>
stretch<br/>
to<br/>
the<br/>
height<br/>
of<br/>
this<br/>
content.
</td>
</tr>
</table>
<!--[if gte mso 9]>
</span></v:textbox>
</v:rect>
<![endif]-->
</td>
</tr>
</table>
我尝试了一些解决方案:
- 将空行的字体大小/行高设置为 0(我在上面的示例代码中这样做了,但它呈现为 1px 而不是 0)
- 使用不同的元素代替表格,以避免出现空行。
-
<p>:不能设置为固定宽度。
-
<div>: 不能有背景色。
-
<span>: 不能呈现为块级元素。
希望有人可以分享这个剩余问题的解决方案。 John B.,如果您可以发布您正在编码的实际代码或布局以及背景图片,这也将有助于确定哪些黑客可能有效以及必须考虑哪些限制。
例如,如果背景图片是 1 像素高的重复图片,您可以使用一排 1 像素宽、具有不同背景颜色的表格单元格来代替实际图片。
[1]:http://msdn.microsoft.com/en-us/library/bb264073%28v=VS.85%29.aspx
[2]:http://msdn.microsoft.com/en-us/library/bb229596%28v=VS.85%29.aspx