Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
531 views
in Technique[技术] by (71.8m points)

css - How to use image as a table background in email?

Stack Overflow users.

We run a newsletter. We need to display an image with text as a header.

We've got a massive personalization for a big user database, so we need a dynamic text overlaying a text image.

What are the options currently supported by most clients?

The obvious plan is to use table's background-image. Supposedly it's not working in Outlook?

There is a fallback plan that's bulletproof in terms of client support: generate an image server-side an include as graphic file. What would be the easiest way to implement it in case nothing else works?

What way would you go? Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Background in Outlook works with VML only. To add an image to a table cell for personlisation i would suggest using the below code:

 <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tbody>
    <tr>
      <td background="[IMAGE GOES HERE]" style="background:url('[IMAGE GOES HERE]'); background-image: url('[IMAGE GOES HERE]');">
  <!--[if gte mso 9]>
  <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:[ADD WIDTH OF IMAGE];height:[ADD IMAGE HEIGHT];">
<v:fill type="frame" src="[IMAGE GOES HERE]" color="[FALLBACK COLOR]" />
<v:textbox inset="0,0,0,0">
  <![endif]--> 

[HTML CONTENT HERE]

<!--[if gte mso 9]>
</v:textbox>
  </v:rect>
  <![endif]-->
  
  
  </td>
    </tr>
  </tbody>
</table>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...