如何在outlook中的时事通讯上制作背景图片?

问题描述 投票:19回答:10

我正在尝试制作时事通讯,其中我有一些图像作为背景和文字。这很容易,但我需要这个工作在Ms Outlook

我尝试过的:

1.

<td width="100" height="100" style="background: url('someurl');">text</td>

2.

<td width="100" height="100" background="someurl">text</td>

3.

<td width="100" height="100">
    <div style="width: 0px; height:0px; position: relative;">
        <div style="width: 100px; height: 100px; position: absolute; background: url('someurl')">
           text
        </div>
    </div>
</td>

但在前景方面没有任何效果。我不知道如何解决它。我正在使用outlook 2007。

任何帮助,将不胜感激。

html background outlook newsletter
10个回答
24
投票

“防弹电子邮件背景图像”的强大工具(适用于Outlook 2007/2010/2013的VML,适用于Outlook 2000/2003,Gmail,Hotmail的HTML / CSS ...)

http://emailbg.net

作为例子:

    <div style="background-color:#f6f6f6;">
  <!--[if gte mso 9]>
  <v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t">
    <v:fill type="tile" src="http://i.imgur.com/n8Q6f.png" color="#f6f6f6"/>
  </v:background>
  <![endif]-->
  <table height="100%" width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr>
      <td valign="top" align="left" background="http://i.imgur.com/n8Q6f.png">
      </td>
    </tr>
  </table>
</div>

为了将指定的背景图像添加到完整的电子邮件正文。

此链接有助于使用矢量标记语言(VML)

msdn.microsoft.com/en-us/library/bb264137%28v=vs.85%29.aspx

www.w3.org/TR/NOTE-VML#_Toc416858389



15
投票

您无法将背景图像添加到要在Outlook中查看的html简报中。它不会工作,因为他们忽略了财产。

你只能在文本后面有块颜色(background-color)。

Outlook不支持以下CSS:

azimuth
background-attachment
background-image
background-position
background-repeat
border-spacing
bottom
caption-side
clear
clip
content
counter-increment
counter-reset
cue-before, cue-after, cue
cursor
display
elevation
empty-cells
float
font-size-adjust
font-stretch
left
line-break
list-style-image
list-style-position
marker-offset
max-height
max-width
min-height
min-width
orphans
outline
outline-color
outline-style
outline-width
overflow
overflow-x
overflow-y
pause-before, pause-after, pause
pitch
pitch-range
play-during
position
quotes
richness
right
speak
speak-header
speak-numeral
speak-punctuation
speech-rate
stress
table-layout
text-shadow
text-transform
top
unicode-bidi
visibility
voice-family
volume
widows
word-spacing
z-index

资料来源:http://msdn.microsoft.com/en-us/library/aa338201.aspx

更新 - 2015年7月

我认为最好更新这个列表,因为它偶尔得到奇怪的upvote - 这里有一个很好的链接到当前的电子邮件客户端支持:https://www.campaignmonitor.com/css/


7
投票

后台可以在Outlook中使用,但仅限于电子邮件的<body>标记。它不适用于个人<td>,只适用于整个电子邮件。

更新:或者您可以使用use the VML method,它允许您将背景图像添加到Outlook中的各个页面元素。

这适用于大多数客户端,包括Outlook:

<body style="background-image: url('img.jpg');">
<table width="100%" background="img.jpg">

以下是适用于所有主要电子邮件客户端(包括Outlook)的完整代码。它具有背景图像集,在100%宽度表中回退到背景。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
</head>
  <body style="margin: 0px; padding: 0px; background-image: url('http://lorempixel.com/output/food-q-c-100-100-7.jpg'); background-color: #0D679C; background-position: top center;" bgcolor="#0D679C">
  <!-- BODY FAKE PANEL -->
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" background="http://lorempixel.com/output/food-q-c-100-100-7.jpg">
      <tr>
        <td>
        <!-- CENTER FLOAT -->
          <table width="800" border="0" valign="top" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
            <tr>
              <td height="1000" align="center" valign="middle">
                Center panel
              </td>
            </tr>
          </table>
        <!-- /CENTER FLOAT -->
        </td>
      </tr>
    </table>
  <!-- /BODY FAKE PANEL -->
  </body>
</html>

1
投票

我能够做到这一点的唯一方法是通过此代码(TD表)。我在Outlook客户端2010中进行了测试。我还通过webmail客户端进行了测试,它对两者都有效。

您唯一需要做的就是更改your_image.jpg(同一图像有两个实例,确保您同时更新代码)和#your_color。

<td bgcolor="#your_color" background="your_image.jpg">

<!--[if gte mso 9]>

<v:image xmlns:v="urn:schemas-microsoft-com:vml" id="theImage" style='behavior: url(#default#VML); display:inline-block; position:absolute; height:300px; width:600px; top:0; left:0; border:0; z-index:1;' src="your_image.jpg"/>

<v:shape xmlns:v="urn:schemas-microsoft-com:vml" id="theText" style='behavior: url(#default#VML); display:inline-block; position:absolute; height:300px; width:600px; top:-5; left:-10; border:0; z-index:2;'>

<![endif]-->

<p>Text over background image.</p>

<!--[if gte mso 9]>

</v:shape>

<![endif]-->

</td>

source


1
投票

您可以使用以下代码:

<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" 
style="width: 700px; height: 460px;">
<v:fill type="tile" src="images/feature-background-01.png" color="#333333" />   
<v:textbox inset="0,0,0,0">                                 
<![endif]-->

注意:将此代码包含在需要背景图像的表格上方。另外,在表的结束标记之后添加下面提到的结束标记。

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

0
投票

并非所有HTML和CSS都受Microsoft Office产品支持,特别是Outlook;在支持的元素上使用look here for reference,以便在呈现HTML时可以和不能在Outlook中使用。

具体来说,从该链接来看,它没有说明background元素支持div CSS属性。您可能必须使用img并进行一些hacky分层。

请注意,在第二个示例中,您的报价不匹配,这对任何报价都没有帮助。

最后,我刚刚在提供的链接中遇到的是Outlook HTML and CSS Validator tool - 您可以尝试针对您的简报标记运行它,看看它是否为您提供任何建议/替代方案。


0
投票

我几个月前在为我的公司工作的WYSIWYG电子邮件编辑器时遇到了这个问题。 Outlook仅支持背景图像,如果它们应用于<body>标记 - 任何其他元素,它将失败。

最后,我找到的唯一解决方法是使用<div>元素进行文本输入,然后在内容提交过程中,我将带有<div>内容的AJAX请求发送到PHP脚本,该脚本将文本写入我们的标题图像的空白版本,保存文件并返回其(唯一生成的)名称。然后我使用Javascript删除<div>并使用<img>属性中返回的文件名添加src标记。

您可以从imagecreatefrompng()上的PHP Docs site页面获取所有信息/方法。


0
投票

Outlook中不支持背景图像。您必须使用图像并使用position relative或absolute将其放置在文本后面。


0
投票

您只能在body标签或表格中使用它。像这样的东西:

<table width="100%" background="YOUR_IMAGE_URL" style="STYLES YOU WANT (i.e. background-repeat)">

这对我有用。

© www.soinside.com 2019 - 2024. All rights reserved.