【问题标题】:display:none is not consistent in outlook but works in chromedisplay:none 在 Outlook 中不一致,但在 chrome 中有效
【发布时间】:2021-12-04 01:33:29
【问题描述】:
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style>
            body {
                font-family: 'Quicksand', sans-serif;
            }            
            .delimiter {
                color: gray;
            }
        </style>
    </head>
    <body bgcolor="#EEEEEE">
        <table align="center" width="800" cellpadding="10" cellspacing="0" border="0" bgcolor="#FFFFFF">
            <tr>
                <td style="display: none;" bgcolor="#FFD500" align="left" width="25%"><img height="40px" src=""></td>
                <td bgcolor="#FFD500" align="center" style="text-align:center; vertical-align:middle; color: #000000; font-family: sans-serif; font-size: 32px;font-weight: bold;" colspan="2">Hello World</td>
                <td style="display: none;" bgcolor="#FFD500" align="right" width="25%"><img height="40px" src=""></td>
            </tr>
        </table>
</body>
</html>

上面的代码是正在使用的 HTML。 HTML 也直接从 Outlook 复制过来,因此 Outlook 电子邮件和 chrome 页面的 HTML 是相同的(相同的 HTML)。

这是我在 chrome 中得到的:https://i.stack.imgur.com/3Nde2.png

这是我在 Outlook 中得到的:https://i.stack.imgur.com/4l6tJ.png

这两个 HTML 代码是相同的,虽然它在 chrome 中可以正常工作,但在 Outlook 中却不能。它应该为两个单元格显示:none,尽管它只对右侧的图像而不是左侧的图像显示。

这也很奇怪,因为它并不是在 Outlook 中不能完全工作,它适用于右侧的单元格/图像,但不适用于左侧的单元格/图像,即使我已经检查过并且它们几乎相同。这可能是什么原因造成的?

我还尝试了围绕我的 tr 标签的 Outlook 条件 CSS (!--[if mso]> 和

【问题讨论】:

  • 您使用的是 Outlook 2007 到 2016 吗? Windows 上的 Outlook (2007-2016) 不支持 display:none。您可以在 或
    上尝试 mso-hide:all。
  • 是的,这很奇怪,因为 display:none 在隐藏右侧的单元格/图像时有效,但不适用于左侧对应项。另外,我刚刚尝试使用 mso-hide:all,尽管由于某种原因它在 Outlook 中仍然给出了相同的结果。 &lt;td style="mso-hide: all;" bgcolor="#FFD500" align="left" width="25%"&gt;&lt;img height="40px" src=""&gt;&lt;/td&gt;
  • 如果您将其应用到表格而不是单个单元格会怎样?
  • 然后整个 hello world 和黄色桌子就消失了。

标签: html css outlook


【解决方案1】:

我找到了这个

style="display:none;width:0px;max-height:0px;overflow:hidden;mso-hide:all;height:0;font-size:0;max-height:0;line-height:0;margin:0 auto;"

litmus.com

即将所有内容都扔到无法正常工作的显示器上:至少在桌面 Outlook 的某些版本上没有。

恐怕我目前无法对此进行真实测试,因此无法确定这是一个可以接受的答案。有兴趣知道它是否适用于您的情况。

【讨论】:

  • 啊,我也发现了。尽管即使尝试过,也没有什么不同。由于某种原因,我仍然最终得到左侧的空白区域。
猜你喜欢
  • 2014-01-15
  • 2014-07-22
  • 2016-02-19
  • 2022-01-23
  • 1970-01-01
  • 1970-01-01
  • 2023-03-22
  • 2013-01-16
  • 2020-04-04
相关资源
最近更新 更多