【问题标题】:Outlook 2010 font foreground/background color CSS not playing nice togetherOutlook 2010 字体前景色/背景色 CSS 不能很好地搭配在一起
【发布时间】:2013-07-17 23:09:45
【问题描述】:

所以,我正在为 Outlook 2010 制作格式为 HTMLCSS 的 MIME 消息。

这是我正在生成的HTML

<!DOCTYPE PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<title>asdfasdf</title>
</head>

<body>

<div style="text-align:left;">
<span style="font-family:'Tahoma';font-size:1em;">
<span style="background-color:#E6E501;">
<span style="color:#0013D6;">asfdasdfad</span></span></span></div>

<div style="text-align:left;">
<span style="font-family:'Tahoma';font-size:1em;">
<span style="background-color:#0A00CE;">
<span style="color:#01D6DE;">asdfasdfasdf</span></span></span></div>

</body>
</html>

这是编辑器在生成之前的样子:

这是 Outlook 2010 显示的内容:

这里是同一在线编辑器中的HTML

这到底是怎么回事?为什么字体颜色仅适用于 Outlook 中的浅色背景而不适用于深色背景?有没有其他人有这个问题? 根据这个网站:http://www.campaignmonitor.com/css/ CSS colorbackground-color 标签都应该被 Outlook 2010 支持。

此外,我制作了单独的跨度,以便我可以轻松查看发生了什么。这不是我们的默认行为,仅用于测试。

【问题讨论】:

    标签: html css background-color html-email outlook-2010


    【解决方案1】:

    在电子邮件中,您应该使用表格而不是 div。您还应该使用 html 的 bgcolor="" 属性声明背景颜色,如下所示:

    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td bgcolor="#E6E501" style="font-family:'Tahoma', sans-serif; sans; font-size:14px; color:#0013D6;">
           asfdasdfad
        </td>
      </tr>
    </table>
    
    <table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td bgcolor="#0A00CE" style="font-family:'Tahoma', sans-serif; sans; font-size:14px; color:#01D6DE;">
           asdfasdfasdf
        </td>
      </tr>
    </table>
    

    我还添加了以像素为单位的字体大小和字体的后备。通常你也会在你的桌子上设置一个 width="" ,但我把它留了下来,因为它更符合你的问题。

    【讨论】:

    • 感谢您的回复。对于这些类型的问题,我查看了您的其他几个答案。为什么 Outlook 想要格式化 tables 而不是 divs。是什么赋予了?考虑到我根本不使用表格,这似乎很不自然。
    • @ToastyMallows 这是因为 Outlook 使用 Microsoft Word 引擎来呈现 html。这个非网络浏览器渲染器注入了一堆额外的代码。可以使用 bgcolor 等内联 html 标记的表格可以在 Outlook 和其他电子邮件客户端中产生更好、更一致的结果。如果有兴趣了解有关电子邮件标准的更多信息:http://www.email-standards.org/
    • 简而言之:Outlook 在呈现 html 方面毫无希望。微软喜欢标准——这就是为什么他们有 120 种不同的标准。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-24
    • 2019-10-06
    • 2013-01-06
    • 1970-01-01
    • 1970-01-01
    • 2013-06-03
    相关资源
    最近更新 更多