You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Outlook的HTML邮件模板中实现背景图文本居中对齐?

Fixing Text Centering in Outlook VML Background TD

Got it, let's tackle this Outlook VML issue—those old versions can be tricky with background images and text alignment! The problem here is that Outlook's VML text box doesn't inherit the CSS centering from the <td>; you have to explicitly set alignment properties directly on the VML elements.

Here's what you need to modify in your code:

  • Add VML-specific alignment styles to the <v:textbox> element:
    • Use v-text-anchor:middle to achieve vertical centering (this is a VML-native property for vertical alignment)
    • Add text-align:center to ensure horizontal centering within the text box
  • Double-check that the <v:rect> dimensions match your <td> exactly (you already have this right, but consistency here helps avoid layout shifts)

Modified Working Code:

<table cellpadding="0" cellspacing="0" border="0" width="600" height="100" align="center">
 <tr>
 <td background="https://picsum.photos/600/100" bgcolor="#ffffff" width="530" height="95" valign="middle" style="background-image: url('https://picsum.photos/600/100');background-repeat:no-repeat; text-align:center; vertical-align:middle;">
 <!--[if gte mso 9]>
 <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:530px;height:95px;color:#ffffff">
 <v:fill type="tile" src="https://picsum.photos/600/100" color="#ffffff" />
 <!-- Added VML-specific alignment styles here -->
 <v:textbox inset="0,0,0,0" style="v-text-anchor:middle; text-align:center;">
 <![endif]-->
 <p style="font-family:Arial, Helvetica, sans-serif; font-size:40px; color:#ffffff; margin: 0;">Your quarterly Update</p>
 <!--[if gte mso 9]>
 </v:textbox>
 </v:rect>
 <![endif]-->
 </td>
 </tr>
</table>

Why your previous CSS didn't work:

Outlook (especially older versions) ignores most modern CSS properties like position:absolute when rendering VML content. You have to use VML-native attributes and styles to control alignment within the VML text box—this is the only reliable way to get consistent centering across Outlook and other email clients.

内容的提问来源于stack exchange,提问作者Rahul Kashyap

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 04:18:04