如何禁用 html 代码块的基础或引导样式?

2023-12-21

我正在使用mailgun(尽管这个问题与mailgun无关)来解析传入的电子邮件,并且mailgun会将解析后的电子邮件http发布到我的服务器。 当我收到帖子时,我得到了多部分电子邮件的 html 代码。 我想向我的用户显示 html 电子邮件,我使用的是 Rails,所以它就像

<div>
  <%= raw(message.body_html) %>
</div>

但是,它看起来与我在 yahoo 或 hotmail 中查看同一封电子邮件时不同(我知道不同的电子邮件客户端会以不同的方式显示 html 电子邮件,但我的看起来截然不同)。

Here is how it looks on my self-built client: html email display in my self-built client

And this is how it looks in yahoo for the same email: html email display in yahoo

我使用 Zurb Foundation 作为我的造型框架。然而,我认为电子邮件 html 带有自己的内联样式,我查看了它看起来确实像的代码,然后它看起来应该与其他客户端足够相似。

那么,假设您获得一段 html 代码并希望按原样显示它而不让其他框架覆盖其样式,那么显示 html 电子邮件的最佳实践是什么?

此外,是否可以禁用代码块的 Foundation(或 twitter bootstrap)样式,例如,类似

<div>
  <% disable_foundation_styling begin %>
    <%= raw(message.body_html) %>
  <% end %>
</div>

当然“disable_foundation_styling”只是我的想象。

提前致谢!

!!!!!!!!!更新 1/1/2013 !!!!!!!!!!!!!!!

As @Alex L. suggested, I tried but it doesn't quiet work as expected. The iframe renders everything in the view as before (see picture below), and that's understandable, since the iframe content is just the view of another controller, which in the case rails will include all the application layout templates as well. However, the toolbar is not my biggest concern, it's what's inside the iframe just looks exactly as before. enter image description here

我怀疑 iframe 可能不是这样做的方法。我查看了gmail和yahoo的代码,他们都不使用iframe。相反,他们使用非常深的嵌套来呈现 html 电子邮件。 html 电子邮件的部分对于 yahoo 和 gmail 具有相同的代码,只是 yahoo 为每个 DOM 元素插入自己的 id。

所以现在我怀疑有一些基础样式影响了它的外观。

一旦我了解更多信息,我会更新。


据我所知,不可能指示浏览器有选择地忽略 DOM 子集中页面的 CSS。您必须显式覆盖页面的现有样式。

但是,如果您有iframe元素,该框架的内容将独立于应用于包含页面的任何样式而呈现。因此,您可以创建一个单独的控制器和视图,仅用于呈现消息的内容,并将其用作消息的源iframe.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何禁用 html 代码块的基础或引导样式? 的相关文章