css – 在Gmail电子邮件中的绝对定位

前端之家收集整理的这篇文章主要介绍了css – 在Gmail电子邮件中的绝对定位前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个客户想要向在其网站上注册用户发送礼券。他们想要它所有的设计,所以我不能只发送文本电子邮件。我试图将文本定位在图像上,以便它仍然是动态的。

我想用绝对定位这样做。一些电子邮件系统喜欢它。有些人讨厌。 Gmail碰巧讨厌它。

我们正在为广告系列使用MailChimp。这是电子邮件的完整来源。以下是只是不工作的代码段。

  1. <html>
  2. <head>
  3. <!-- This is a simple example template that you can edit to create your own custom templates -->
  4. <Meta http-equiv="Content-type" content="text/html; charset=utf-8">
  5. <title>*|MC:SUBJECT|*</title>
  6.  
  7. <style type="text/css">body{background-color:#bab145;text-align:center;}#layout{border:5px solid #999999;background:#ffffff;margin:10px auto;text-align:left;}#header{background-color:#cccccc;padding:0px;color:#333333;font-size:30px;font-family:Georgia;text-align:left;}#content{font-size:13px;color:#4d4d4d;font-family:Helvetica;line-height:1.25em;padding:10px 30px;}.primary-heading{font-size:28px;font-weight:bold;color:#8b0000;font-family:Georgia;line-height:150%;margin:25px 0 0 0;}.secondary-heading{font-size:20px;font-weight:bold;color:#000000;font-style:normal;font-family:Georgia;margin:25px 0 5px 0;}#footer{background-color:#eeeeee;border-top:0px none #ffffff;padding:20px;font-size:10px;color:#333333;line-height:100%;font-family:Verdana;}#footer a{color:#800000;text-decoration:underline;font-weight:normal;}a,a:link,a:visited{color:#800000;text-decoration:underline;font-weight:normal;}</style></head>
  8. <body style="background-color: #bab145;text-align: center;">
  9. <table id="layout" border="0" cellspacing="0" cellpadding="0" width="600" style="border: 5px solid #999999;background: #ffffff;margin: 10px auto;text-align: left;">
  10.  
  11.  
  12. <tr>
  13. <td id="content" style="font-size: 13px;color: #4d4d4d;font-family: Helvetica;line-height: 1.25em;padding: 10px 30px;"><div style="height:243px; width: 500px; position: relative;">
  14. <img src="http://getfreepellets.com/images/GC_flat.jpg" style="position: absolute;">
  15. <div style="position: absolute; top: 110px; left: 130px;">
  16. *|FNAME|* *|LNAME|*</div>
  17. <div style="position: absolute; top: 140px; left: 130px;">
  18. GetFreePellets.com</div>
  19. <div style="position: absolute; top: 166px; left: 130px;">
  20. $100</div>
  21. <div style="position: absolute; top: 200px; left: 370px;">
  22. *|COUPONCODE|*</div>
  23. </div>
  24. </td></tr>
  25.  
  26. <tr>
  27. <td id="footer" style="background-color: #eeeeee;border-top: 0px none #ffffff;padding: 20px;font-size: 10px;color: #333333;line-height: 100%;font-family: Verdana;">
  28. <p><a href="*|ARCHIVE|*" class="adminText" style="color: #800000;text-decoration: underline;font-weight: normal;">view email in browser</a> | <a href="*|UNSUB|*" style="color: #800000;text-decoration: underline;font-weight: normal;">Unsubscribe</a> *|EMAIL|* | <a href="*|UPDATE_PROFILE|*" style="color: #800000;text-decoration: underline;font-weight: normal;">Update your profile</a> | <a href="*|FORWARD|*" style="color: #800000;text-decoration: underline;font-weight: normal;">Forward to a friend</a></p>
  29.  
  30. <p>*|LIST:DESCRIPTION|*</p>
  31.  
  32. <p>*|HTML:LIST_ADDRESS_HTML|*</p>
  33. <p>Copyright (C) *|CURRENT_YEAR|* *|LIST:COMPANY|* All rights reserved.</p>
  34. </td>
  35. </tr>
  36. </table>
  37. <span style="padding: 0px;"></span>
  38. <center><table width="95%" style="clear:both;margin:0px !important;padding:0px !important;margin-top:20px !important;border-top:1px solid #999 !important;border-bottom:1px solid #999 !important;" cellpadding="0" cellspacing="0"><tr>
  39. <td align="left" style="padding:10px !important;margin:0px !important;color:#666 !important;background:#CCC !important;width:50% !important;border-bottom 1px solid #999 !important;font-family:Verdana,Arial,Sans !important;font-size:11px !important;font-weight:normal !important;font-style:normal !important;text-decoration:none !important;vertical-align:middle !important;text-align:left !important;">
  40. Sent to *|EMAIL|*. <a href="*|UNSUB|*" style="font-family:Verdana,Sans !important;font-size:11px !important;font-weight:normal !important;font-style:normal !important;text-decoration:none !important;color:#03C !important;">Unsubscribe</a> |
  41. <a href="*|UPDATE_PROFILE|*" style="font-family:Verdana,Sans !important;font-size:11px !important;font-weight:normal !important;font-style:normal !important;text-decoration:none !important;color:#03C !important;">Update Profile</a> |
  42. <a href="*|FORWARD|*" style="font-family:Verdana,Sans !important;font-size:11px !important;font-weight:normal !important;font-style:normal !important;text-decoration:none !important;color:#03C !important;">Forward to a Friend</a>
  43. </td>
  44. <td align="right" style="padding:10px !important;margin:0px !important;color:#666 !important;background:#CCC !important;width:50% !important;border-bottom 1px solid #999 !important;vertical-align:middle !important;text-align:right !important;">
  45. *|REWARDS|*
  46. </td>
  47. </tr></table></center></body>
  48. </html>

只是我担心的片段:

  1. <tr>
  2. <td id="content" style="font-size: 13px;color: #4d4d4d;font-family: Helvetica;line-height: 1.25em;padding: 10px 30px;"><div style="height:243px; width: 500px; position: relative;">
  3. <img src="http://getfreepellets.com/images/GC_flat.jpg" style="position: absolute;">
  4. <div style="position: absolute; top: 110px; left: 130px;">
  5. *|FNAME|* *|LNAME|*</div>
  6. <div style="position: absolute; top: 140px; left: 130px;">
  7. GetFreePellets.com</div>
  8. <div style="position: absolute; top: 166px; left: 130px;">
  9. $100</div>
  10. <div style="position: absolute; top: 200px; left: 370px;">
  11. *|COUPONCODE|*</div>
  12. </div>
  13. </td></tr>

注意:MailChimp合并变量是|之间的那些事和|。

这里是一个看起来像在Entourage的图像。红色的酒吧是一个真正的名字,所以.. ya:

这里是在gmail(我知道名字没有审查):

任何想法如何使这工作在Gmail?

解决方法

不幸的是,你不能使用position:absolute。

此外,由于Outlook使用Word HTML渲染器,您也将遇到使用绝对定位的问题。

大多数HTML电子邮件都是用表格布局的。

Check this out

猜你在找的CSS相关文章