如何让 MS Outlook 接受 CSS 样式 display:block?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8989161/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:44:56  来源:igfitidea点击:

How do I get MS Outlook to accept the CSS style display:block?

cssoutlookoutlook-2010

提问by mmcglynn

I am composing an HTML email using a service (MailChimp). The way that MailChimp marks up headings is to use a SPANtag and gives the tag the inline style of display:block.

我正在使用服务 (MailChimp) 撰写 HTML 电子邮件。MailChimp 标记标题的方式是使用SPAN标签并赋予标签内联样式display:block.

MS Outlook 2010 ignores this style. I cannot find any work around. Thus, headings wrap, breaking the desired page display.

MS Outlook 2010 忽略此样式。我找不到任何解决方法。因此,标题换行,破坏了所需的页面显示。

Yes, I know that Outlook uses MS Word to display HTML.

是的,我知道 Outlook 使用 MS Word 来显示 HTML。

Assume that I cannot intervene and hand edit the markup.

假设我无法干预和手动编辑标记。

How do I get MS Outlook to accept the CSS style display:blockand display a SPANtag as a block level element?

如何让 MS Outlook 接受 CSS 样式display:block并将SPAN标签显示为块级元素?

回答by Diodeus - James MacFarlane

The CSS displayattribute is not supported in this version of MS Outlook.

display此版本的 MS Outlook 不支持CSS属性。

Here's "The Book" on what you can and cannot use:

这是关于您可以使用和不可以使用的内容的“The Book”:

campaignmonitor.com/css/

Campaignmonitor.com/css/

Basically, if you can't change your mark-up to a natively-block item, you're stuck.

基本上,如果你无法将加价更改为原生-阻塞的项目,你就完蛋了。

回答by lenard-magentoinks

The best thing is to do it the old fashion way unfortunately. =[ Use tables over tables. so tables=blocks.

不幸的是,最好的办法是用旧时尚的方式来做。=[ 在表格上使用表格。所以表=块。

回答by Noah Manger

I found myself in this exact situation: needing to create header styles that displayed correctly in outlook without the ability to edit the HTML because I'm handing the template off to a client.

我发现自己处于这种确切的情况:需要创建在 Outlook 中正确显示的标题样式,但无法编辑 HTML,因为我将模板交给客户。

I imagine you've already solved this, but to anyone else who spent several hours trying to answer this question and stumbles across this thread, here's how I fixed it:

我想你已经解决了这个问题,但是对于花了几个小时试图回答这个问题并偶然发现这个线程的其他人,我是这样修复它的:

  1. Delete Mailchimp's default H1, H2, etc.

  2. Create your own header styles (I named them Header, Sub-Header, etc. just to avoid confusion)

  3. Use the new header styles as you wish. The new headings display as blocks.

  1. 删除Mailchimp的默认H1、H2等。

  2. 创建您自己的标题样式(我将它们命名为 Header、Sub-Header 等,以避免混淆)

  3. 根据需要使用新的标题样式。新标题显示为块。

I'm not exactly sure what's going on under the hood as I can't inspect in Outlook, but my guess is that by not using the default styles either Mailchimp wraps the header text in divs instead of spans.

我不确定内部发生了什么,因为我无法在 Outlook 中检查,但我的猜测是,如果不使用默认样式,Mailchimp 会将标题文本包装在 div 中而不是跨度中。