【问题标题】:HTML Email - button has no padding on outlookHTML 电子邮件 - 按钮在 Outlook 上没有填充
【发布时间】:2021-11-12 12:01:32
【问题描述】:

我想知道是否可以使用与上面按钮相同的填充来制作边框。解决方案似乎是当我将边框添加到 td 时,但我不能这样做,因为在其他客户端中,边框具有此处不可见的边框半径。有任何想法吗?谢谢

第二个按钮的代码:

<!-- BUTTON -->
<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" class="fluid" 
    role="presentation" width="600">
    <tr>
        <td align="center" bgcolor="#ffffff" style="padding: 0 0 40px 0;" 
            valign="top">
            <table align="center" border="0" cellpadding="0" cellspacing="0" 
                class="main-button-mob-width" role="presentation"
                    style="max-width: 80%; min-width: auto;">
                <tr>
                    <td align="center" bgcolor="#ffffff" 
                        class="out-main-button-padding" 
                        style="border-radius: 50px; padding: 0; font-family: 
                        'Arial Black', Gadget, Arial, 
                        Helvetica, sans-serif; font-size: 18px; font-weight: bold; 
                        line-height: 22px; mso-text-raise: 4px;"
                        valign="top">
                        <a class="out-main-button-a"
                            href="#" style="display: block; 
                            border-radius: 50px; background-color: #ffffff; 
                            border: 3px solid #061539; 
                            mso-border-alt: 8px solid #061539; 
                            padding: 15px 35px 15px 35px; mso-padding-alt: 4px; 
                            color: #061539; text-decoration: none;"
                            target="_blank" title="">
                            <span style="color: #061539; text-decoration: none; 
                                background-color: #ffffff">INVITA A TUS AMIGOS
                            </span>
                        </a>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<!-- BUTTON end -->

【问题讨论】:

  • 您的标题是关于填充的,但您的问题是关于边界的。差异很明显,但很难理解问题所在。 a 上有 border-radius: 50px;。如果您删除它,它们会更相似。
  • 好吧,我注意到没有填充,所以边框看起来不一样。很明显,因为“a”是内联元素,但border-raius 在其他任何地方都不起作用。边界必须在那里,边界半径也必须在那里。唯一的问题是,在前景中,边框半径不可见,但在其他客户端中却是..我只需要按钮的宽度/高度与周围的边框相同..

标签: html email button html-email


【解决方案1】:

在 Outlook 中,您不能将内联元素(例如 &lt;a&gt;)更改为块元素 (display:block)。因此它会忽略填充、边距等,因为这些是块元素样式。

因此,为了跨电子邮件兼容性,您要么需要在&lt;td&gt; 上添加填充(这不会扩展可点击部分,而只会使其看起来像按钮更大,或者,您可以按照 Mark Robbins 的描述应用 hack。

解决方案 1:(最简单的)TD 按钮

<td align="center" bgcolor="#ffffff" 
    class="out-main-button-padding" 
    style="border-radius: 50px; padding: 15px 35px 15px 35px;
    border-radius: 50px; background-color: #ffffff; 
    border: 3px solid #061539; 
    mso-border-alt: 8px solid #061539; 
    mso-padding-alt: 4px;  font-family: 
    NIVEaBrandType-Bold, 'Arial Black', Gadget, Arial, 
    Helvetica, sans-serif; font-size: 18px; font-weight: bold; 
    line-height: 22px; mso-text-raise: 4px;"
    valign="top">
    <a class="out-main-button-a"
        href="https://nivea.com" style="display: block; 
        color: #061539; text-decoration: none;"
        target="_blank" title="">
        <span style="color: #061539; text-decoration: none; 
            background-color: #ffffff">INVITA A TUS AMIGOS
        </span>
    </a>
</td>

我所做的只是将块级样式从&lt;a&gt; 移动到&lt;td&gt;。您仍然可以将display:block 留在&lt;a&gt; 上,以便为支持此功能的电子邮件客户端扩大可点击区域。

解决方案 2:Mark Robbin 的 A 按钮

<a href="https://example.com/" style="background: #333; border: 2px solid #f00; text-decoration: none; padding: 15px 25px; color: #fff; border-radius: 4px; display:inline-block; mso-padding-alt:0;text-underline-color:#333"><!--[if mso]><i style="letter-spacing: 25px;mso-font-width:-100%;mso-text-raise:30pt" hidden>&nbsp;</i><![endif]--><span style="mso-text-raise:15pt;">Link Text</span><!--[if mso]><i style="letter-spacing: 25px;mso-font-width:-100%" hidden>&nbsp;</i><![endif]-->
</a>

通过更改letter-spacing 值(在链接文本的左侧和右侧)来更改左右填充。

通过更改&lt;span&gt; 中的mso-text-raise 值来更改底部填充。

通过更改&lt;i&gt; 中的mso-text-raise 值来更改顶部填充。

https://www.goodemailcode.com/email-code/link-button详细解释)

【讨论】:

  • 顺便说一句,在 Outlook 中添加边框半径是可能的,但您必须使用 VML。在此处查看完整的文章litmus.com/blog/a-guide-to-bulletproof-buttons-in-email-design
  • 非常感谢!!第二个解决方案解决了我的问题!第一个的唯一问题是边界半径在任何地方都不起作用,但我需要在客户支持它的任何地方都有它,没有它是可以的:) 但我会看看你的 VML正在讨论,谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-19
  • 2012-11-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多