简体   繁体   English

在HTML电子邮件中叠加图像

[英]Overlay Image in HTML email

I am creating an html template, this template contains text and image. 我正在创建一个html模板,该模板包含文本和图像。 Now, we want the image to position above the text just to hide some part of the text (it has a purpose). 现在,我们希望图像位于文本上方,只是为了隐藏文本的某些部分(有目的)。 I already tried to use absolute position for the image but it don't work when it is viewed on email. 我已经尝试过使用图像的绝对位置,但是在电子邮件上查看时它不起作用。 Is there any tricks to do this? 有什么技巧可以做到这一点吗?

<div class="wrap" style="color: #4E4E4E; font-family: Calibri, Candara, Segoe, 'Segoe UI', Optima, Arial, sans-serif; max-width:600px; margin:0 auto;position:relative;">    

<div class="e_body" style="max-width:600px">
<div class="e_head" style="position:absolute; width: 100%;text-align:center;">
<img src="http://i.imgur.com/EmNU0CO.jpg">
</div>

<p>"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
</p>
<p>"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
</p>
</div>
</div>

http://jsfiddle.net/2fH2G/ http://jsfiddle.net/2fH2G/

Is there any tricks to do this? 有什么技巧可以做到这一点吗?

When working with html in emails, the rules change. 在电子邮件中使用html时,规则会更改。 Most ways to position elements using css on websites do not work. 在网站上使用CSS定位元素的大多数方法都不起作用。 What I usually end up doing is using tables to put things where they need to be, as annoying as that sounds and is to do. 我通常最终要做的是使用表将事物放置在需要的地方,听起来和要做的事都很烦人。 Also, links and images have to be full path ( http://www.example.com/mypage.html instead of mypage.html) or they won't work in the sent email. 另外,链接和图像必须是完整路径( http://www.example.com/mypage.html而不是mypage.html),否则它们将在发送的电子邮件中不起作用。 Another thing is, style-sheets rarely work, and inline styles are the way to go. 另一件事是,样式表很少起作用,而内联样式是必经之路。 Basically break all the rules you knew for html on web pages. 基本上可以打破您对网页上html所了解的所有规则。

Finally, every email client shows html emails different ways, so be aware that what you see may not be what the recipient sees. 最后,每个电子邮件客户端以不同的方式显示html电子邮件,因此请注意,您看到的可能不是收件人看到的。 As to your specific problem though, we need to see your code. 不过,对于您的特定问题,我们需要查看您的代码。

Can't be done in html email (at least consistently across clients anyway). 无法在html电子邮件中完成(无论如何,至少在客户端中始终如此)。 You should read up on the limitations of html email design - here are some resources 您应该阅读有关html电子邮件设计的限制- 这里有一些资源

What you need to do is use the background image property in css on a cell. 您需要做的是在单元格的css中使用background image属性。

For example, say I have two images. 例如,假设我有两个图像。 I can overlay them like so: 我可以像这样覆盖它们:

<td style="background:url('/images/image1.png');">
  <img src="/images/image2.png" />
</td>

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

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