【问题标题】:Hide HTML Elements when printing in Microsoft Outlook在 Microsoft Outlook 中打印时隐藏 HTML 元素
【发布时间】:2013-10-11 23:14:27
【问题描述】:

我想在打印时在我的 HTML 格式消息中隐藏一个表格。它有一个 class="noprint" 属性。其他彬彬有礼的邮件客户端尊重 CSS 规则和媒体查询,我需要做的就是添加一个基本样式表:

@media print {
     .noprint { display: none; }
}

我从this article 看到 Outlook 和 Word 不支持媒体查询。

有人知道解决方法吗?

【问题讨论】:

标签: html css printing outlook


【解决方案1】:

有一个条件 css 解决方法。将此代码添加到您的主 css 文件中。

<!--[if gte mso 9]>
    <style type="text/css">
        .noprint { display: none; }
    </style>
<![endif]-->

希望这会有所帮助。

【讨论】:

  • 这很有帮助,但我还是想在屏幕上显示内容,而不是在打印上。
【解决方案2】:

mso-hide:all 本身是行不通的。它是 Microsoft Word 引擎的供应商特定属性。为了在桌面上隐藏/在移动设备上显示,您需要额外的属性。以下是您需要使用的一些附加属性:

*[class="hide"] {
    max-height:0; /* Gmail*/
    display:none; /* Generic*/
    mso-hide:all; /* Outlook clients*/
    overflow:hidden; /* Generic */
    font-size:0; /* Be careful with this one, only use if absolutely required */
} 

然后在媒体查询中,您希望覆盖任何设置为与隐藏相反的值。

还请注意mso-hide:all,如果您尝试隐藏包含嵌套表格的表格单元格中的内容,您还必须将此属性应用于其中的任何和所有嵌套表格。

【讨论】:

    猜你喜欢
    • 2020-03-11
    • 2011-01-22
    • 2010-09-26
    • 2016-04-26
    • 2021-06-06
    • 1970-01-01
    • 2012-08-26
    • 2011-12-04
    相关资源
    最近更新 更多