html - 电子邮件模板 - 背景图像与文本叠加在确切位置

标签 html css email outlook html-email

我正在构建一个 HTML 邮件,其中应该是一个图像,上面有一个数字。 到目前为止,我已将图像添加为 td 背景,并使用嵌套表格来定位文本。它在大多数电子邮件客户端中看起来都不错,除了… Outlook。 Outlook 呈现文本 - 向右(Outlook 2003) - 太高(Outlook 2007 及更高版本)

示例: https://s31.postimg.org/6rhbz8diz/Schermafbeelding_2016_07_28_om_19_58_07.png

<table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td background="https://s31.postimg.org/57s9ntmij/basket_3.png" bgcolor="#ffffff" width="35" height="30" valign="top" style="font-size: 0;">
            <!--[if gte mso 9]>
            <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:35px;height:30px;">
                <v:fill type="frame" src="https://e.kaartje2go.nl/public/Kaartje2go/8553f93ebcf5d20eb1da4a3b8abeaaba/basket_3.png" color="#ffffff" />
                <v:textbox inset="0,0,0,0">
                    <![endif]-->
                    <table cellpadding="0" cellspacing="0" border="0" width="30" style="line-height:20px;">
                        <tr>
                            <td width="20"></td>
                            <td height="15" align="center" valign="middle" style="font-size: 12px; font-family: 'Source Sans Pro', Arial, sans-serif; color:#ffffff;font-weight:700; line-height:20px;" >
                                2
                            </td>
                        </tr>
                    </table>
                    <!--[if gte mso 9]>
                </v:textbox>
            </v:rect>
            <![endif]-->
        </td>
    </tr>
</table>

可以在此处找到 HTML:http://codepen.io/anon/pen/kXpKRQ?editors=1000

我尝试了不同的高度和行高,但似乎没有任何帮助。 有人可以帮我修复文本的位置吗? 非常感谢!

最佳答案

我已经用行高值解决了这个问题(更多)。

在表本身及其父表中定义了多个行高。我删除了父级的行高并更改了 td 行高和宽度的值以修复 Gmail 应用中的对齐问题。

这是最终的解决方案:

<table width="35" cellpadding="0" cellspacing="0" border="0">
  <tr>
    <td background="https://s31.postimg.org/57s9ntmij/basket_3.png" bgcolor="#ffffff" width="35" height="30" valign="top" style="font-size: 0;">
      <!--[if gte mso 9]>
         <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:35px;height:30px;">
            <v:fill type="frame" src="https://s31.postimg.org/57s9ntmij/basket_3.png" color="#ffffff" />
            <v:textbox inset="0,0,0,0">
               <![endif]-->
      <table cellpadding="0" cellspacing="0" border="0" width="35">
        <tr>
          <td width="14"></td>
          <td width="21" height="20" align="center" valign="middle" style="font-size: 12px; font-family: 'Source Sans Pro', Arial, sans-serif; color:#ffffff;font-weight:700; line-height:14px;">
            2
          </td>
        </tr>
      </table>
      <!--[if gte mso 9]>
            </v:textbox>
         </v:rect>
         <![endif]-->
    </td>
  </tr>
</table>

它在大多数电子邮件客户端中表现良好(Outlook 120 DPI 除外......)

关于html - 电子邮件模板 - 背景图像与文本叠加在确切位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38643874/

相关文章:

javascript - 我正在尝试验证我的 html 表单,但我的 JS 脚本无法正常工作,当我单击“提交”按钮时,除了我的页面重新加载之外,没有任何反应

php - HTML 和 PHP - 如何使多个表单可提交

Javascript:网站标题幻灯片淡入效果

javascript - Materialize CSS,显示自动完成芯片的图像

c# - 如何发送带有 PDF 文件的邮件

java - 亚马逊 AWS SES : Email fails using SDK but works on console. 表示电子邮件地址未验证

c# - 用封闭的 HREFS 替换电子邮件和 HREFS

javascript - 将我的 Javascript 数组放入表中

c# - 从 html 单选按钮获取值 - 在 aspx-c#

html - CSS first-of-type 适用于所有人