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

Outlook邮件中VML圆角按钮与相邻文本不对齐问题求助

问题描述

需在p标签旁放置圆角按钮,因此使用VML标签实现样式,在Outlook中测试时发现按钮位置略微偏上,无法与旁边的文本居中对齐。

原始代码
<table>
   <tr>
      <td>
         <p style="font-size:11pt;font-family:Arial,Verdana,sans-serif;margin-left:20px; line-height:1.2">
            So you don’t miss out, during EADV we’d like to send you daily reminders. If you’d prefer not to receive these please let us know
            <!--[if mso]>
            <span style="text-decoration:none;display:inline-block;color:white;background-color:#1A55A6;border-radius:25px;-webkit-border-radius:25px;-moz-border-radius:25px;width:auto;padding-top:5px;padding-bottom:5px;font-family:'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Geneva, Verdana, sans-serif;text-align:center;mso-border-alt:none;word-break:keep-all;">
               <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="https://cloud.info.ucb.com/eadv?accountId=%%=v(@accountId)=%%&eventId=%%=v(@eventId)=%%&optIn=%%=v(@optIn)=%%" style="height:20pt;width:50pt;v-text-anchor:middle;"  arcsize="45%" strokeweight="0.75pt" inset="0,0,0,0" strokecolor="#1A55A6" fillcolor="#1A55A6">
                  <v:textbox inset="0,0,0,0">
         <center style="color:white; font-family:Verdana, sans-serif; font-size:15px">
         <![endif]-->
         <a alias="" class="buttonstyles" conversion="false" data-linkto="http://" href="https://cloud.info.ucb.com/eadv?accountId=%%=v(@accountId)=%%&eventId=%%=v(@eventId)=%%&optIn=%%=v(@optIn)=%%" target="_blank" title="ics1"><span style="padding-left:5px;padding-right:5px;font-size:14px;display:inline-block;letter-spacing:normal;color:white"><span dir="ltr" style="mso-line-height-alt: 24px;">
         <strong>here</strong>
         </span></span></a></span>
         <!--[if mso]></v:textbox></v:roundrect><![endif]--> 
         </p>
      </td>
   </tr>
</table>
效果截图

Outlook中按钮显示效果图

修复方案
  • 给<v:roundrect>标签的style属性添加vertical-align:middle,Outlook中VML元素默认无垂直对齐规则,显式指定后即可和同行文本居中对齐
  • 将p标签的line-height调整为20pt,和按钮高度保持一致,统一行内元素的对齐基准
  • 给MSO条件注释内包裹按钮的span标签也添加vertical-align:middle,兼容不同版本Outlook的渲染逻辑
修复后代码示例
<table>
   <tr>
      <td>
         <p style="font-size:11pt;font-family:Arial,Verdana,sans-serif;margin-left:20px; line-height:20pt">
            So you don’t miss out, during EADV we’d like to send you daily reminders. If you’d prefer not to receive these please let us know
            <!--[if mso]>
            <span style="text-decoration:none;display:inline-block;vertical-align:middle;color:white;background-color:#1A55A6;border-radius:25px;-webkit-border-radius:25px;-moz-border-radius:25px;width:auto;padding-top:5px;padding-bottom:5px;font-family:'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Geneva, Verdana, sans-serif;text-align:center;mso-border-alt:none;word-break:keep-all;">
               <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="https://cloud.info.ucb.com/eadv?accountId=%%=v(@accountId)=%%&eventId=%%=v(@eventId)=%%&optIn=%%=v(@optIn)=%%" style="height:20pt;width:50pt;v-text-anchor:middle;vertical-align:middle;"  arcsize="45%" strokeweight="0.75pt" inset="0,0,0,0" strokecolor="#1A55A6" fillcolor="#1A55A6">
                  <v:textbox inset="0,0,0,0">
         <center style="color:white; font-family:Verdana, sans-serif; font-size:15px">
         <![endif]-->
         <a alias="" class="buttonstyles" conversion="false" data-linkto="http://" href="https://cloud.info.ucb.com/eadv?accountId=%%=v(@accountId)=%%&eventId=%%=v(@eventId)=%%&optIn=%%=v(@optIn)=%%" target="_blank" title="ics1"><span style="padding-left:5px;padding-right:5px;font-size:14px;display:inline-block;vertical-align:middle;letter-spacing:normal;color:white"><span dir="ltr" style="mso-line-height-alt: 24px;">
         <strong>here</strong>
         </span></span></a></span>
         <!--[if mso]></v:textbox></v:roundrect><![endif]--> 
         </p>
      </td>
   </tr>
</table>

内容的提问来源于stack exchange,提问作者jay kay

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.04 06:18:01