简体   繁体   English

在大多数台式机和Web电子邮件客户端兼容的HTML电子邮件中向图像添加覆盖图

[英]Add Overlay to Image in HTML EMail Compatible With Most Desktop and Web EMail Clients

Is there a way in 2017 to display either an image- or text-based overlay over the main image inside an HTML email, so that it is properly rendered by most of the current Desktop and Web email clients : Outlook 2007+, Thunderbird, Mobile Clients, GMail, Outlook.com, Yahoo Mail, etc.? 2017年是否有办法在HTML电子邮件中的主图像上显示基于图像或基于文本的叠加层 ,以便大多数当前的桌面和Web电子邮件客户端 (Outlook 2007 +,Thunderbird,Mobile)都能正确呈现该图像客户,GMail,Outlook.com,Yahoo Mail等?

As an example, it could be a small play button rendering over the main image, that when clicked would take you to a video url. 例如,它可能是在主图像上呈现的一个小播放按钮,单击该按钮将带您到视频URL。

Yes, although it requires a lot of code since Outlook doesn't support CSS background-image , so we have to use VML in addition to CSS to get a background image displaying everywhere. 是的,尽管由于Outlook不支持CSS background-image ,所以它需要很多代码,所以除了 CSS 之外 ,我们还必须使用VML来使背景图像显示在各处。 backgrounds.cm is a good starting point but hasn't been updated in some time. backgrounds.cm是一个很好的起点,但是一段时间未更新。 Something like this is a good starting point to build on: 这样的事情是建立的良好起点:

<tr>
    <!-- Bulletproof Background Images c/o https://backgrounds.cm -->
    <td background="http://placehold.it/600x180/222222/666666" bgcolor="#222222" valign="middle" style="background-position: center center !important; background-size: cover !important;">
        <!--[if gte mso 9]>
        <v:image xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="border: 0; display: inline-block; width: 600px; height: 180px;" src="http://placehold.it/600x180/222222/666666" />
        <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="border: 0; display: inline-block; position: absolute; width: 600px; height: 180px;">
        <v:fill opacity="0%" color="#222222" />
        <![endif]-->
        <div>
            <!--[if mso]>
            <table role="presentation" border="0" cellspacing="0" cellpadding="0" align="center" width="600">
            <tr>
            <td align="center" valign="top" width="600">
            <![endif]-->
            <table role="presentation" border="0" cellpadding="0" cellspacing="0" align="center" width="100%">
                <tr>
                    <td valign="middle" style="padding: 20px; color: #ffffff;">
                        <img src="http://placehold.it/100" height="100" width="200" alt="">
                        <p style="margin: 0;">Maecenas sed ante pellentesque, posuere leo id, eleifend dolor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Praesent laoreet malesuada cursus. Maecenas scelerisque congue eros eu posuere. Praesent in felis ut velit pretium lobortis rhoncus ut&nbsp;erat.</p>
                    </td>
                </tr>
            </table>
            <!--[if mso]>
            </td>
            </tr>
            </table>
            <![endif]-->
        </div>
        <!--[if gte mso 9]>
        </v:fill>
        </v:rect>
        </v:image>
        <![endif]-->
    </td>
</tr>

Using VML is still the only way to get background image support on Outlook environments. 使用VML仍然是在Outlook环境中获得背景图像支持的唯一方法。 So you'll want to use this tool https://backgrounds.cm/ 因此,您将需要使用此工具https://backgrounds.cm/

Drop your image url in, set it to 'single table sell' and set some dimensions, then you just build your overlay content between the <div> tags 放入图片url,将其设置为“单桌出售”并设置一些尺寸,然后您只需在<div>标签之间构建覆盖内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM