Gmail 将某些 HTML 元素包装在名为 im 的类中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16689882/
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-29 08:41:25  来源:igfitidea点击:

Gmail wraps certain HTML elements in a class called im

htmlgmail

提问by klewis

I have been testing out an HTML e-mail process I've created recently. But as of lately, when I open the e-mail in Gmail, I'm noticing that certain elements are wrapped in a class that I know I didn't put in the original HTML layout. In fact I just triple checked! When viewing the HTML email in Gmail, random sections of my form are being wrapped with...

我一直在测试我最近创建的 HTML 电子邮件进程。但是最近,当我在 Gmail 中打开电子邮件时,我注意到某些元素被包装在一个我知道我没有放入原始 HTML 布局的类中。事实上,我只是检查了三次!在 Gmail 中查看 HTML 电子邮件时,我的表单的随机部分被包裹...

<div class="im">
....
</div>

As a result, some text turns purple, while other text does not. Why does this happen?

因此,某些文本会变成紫色,而其他文本不会。为什么会发生这种情况?

Thanks

谢谢

回答by Derek Henderson

Gmail seems to think that you are quoting other emails in a conversation and so is wrapping div.imaround the sections of your code that it thinks are previous bits in a conversation.

Gmail 似乎认为您在对话中引用了其他电子邮件,因此将div.im它认为是对话中先前部分的代码部分包装起来。

This might happen if your code has a TABLE with more than one TR. To get around this, rather than several TRs in one TABLE, use several TABLEs with one TR in each.

如果您的代码有一个包含多个 TR 的 TABLE,则可能会发生这种情况。为了解决这个问题,不要在一个 TABLE 中使用多个 TR,而是使用多个 TABLE,每个 TABLE 中有一个 TR。

This might also happen if you have multiple subject lines that are the same, causing Gmail to think this is a conversation. You can fix this by making each subject line unique.

如果您有多个相同的主题行,导致 Gmail 认为这是一个对话,也可能会发生这种情况。您可以通过使每个主题行唯一来解决此问题。

回答by stevecomrie

I also experienced this problem when using a paragraph with single line breaks in it like this:

在使用带有单换行符的段落时,我也遇到了这个问题,如下所示:

<p>
   line 1<br>
   line 2<br>
   line 3
</p>

I was able to correct the problem from happening in Gmail from removing all the blank space from that specific part of HTML and bringing that entire paragraph and all it's contents back flush against the left edge of the screen. Sure it looks a little messy and you lose your proper indenting, but I think this helps Gmail not accidentally think you're quoting something inline.

我能够纠正 Gmail 中发生的问题,方法是从 HTML 的特定部分删除所有空格,并将整个段落及其所有内容重新对齐屏幕左边缘。当然它看起来有点乱,而且你失去了正确的缩进,但我认为这有助于 Gmail 不会意外地认为你在引用内联内容。

回答by Zack

Separate style files do not work for emails. What you can do though is add style for this class in the html as follows:

单独的样式文件不适用于电子邮件。您可以做的是在 html 中为此类添加样式,如下所示:

  <head>
       <style type="text/css">
        .im {
           color: #000000 !important;
        }
    </style>
  </head>

This should give style to the class .imin case its found

这应该为类.im提供样式,以防它找到

回答by liwanglin12

I have this issue too. And I just added a five-bit random charto every line end and set the color like the background. Then the issue got fixed.

我也有这个问题。我只是char在每行末尾添加了一个五位随机数,并将颜色设置为背景。然后问题就解决了。

It's not a good way, but if no another way, maybe you can try it.

这不是一个好方法,但如果没有其他方法,也许你可以尝试一下。

回答by Stefan Doskovi?

You ignore style of im class on this way

你以这种方式忽略了 im 类的风格

<b style="color:black;">Some text</b>

Some text does not have purple color

有些文字没有紫色

回答by Дима Д

Please use styles on your page:

请在您的页面上使用样式:

div.adm {  display: none !important;}
div.h5 { display: block !important;}

回答by Arif Hossain

I had similar problems. I was sending emails from an application using templates. So, when I sent multiple emails to same address, lines that are exactly same in all of them got purple. Gmail added this tag automatically:

我有类似的问题。我正在使用模板从应用程序发送电子邮件。因此,当我向同一个地址发送多封电子邮件时,所有邮件中完全相同的行都变成了紫色。Gmail 自动添加了这个标签:

<div class="im">
.........
</div>

I do not know that for a fact, seemed to me Gmail wraps the common texts in a conversation with the this tag. Similar discussion here.

我不知道事实上,在我看来,Gmail 将常见文本包装在带有 this 标签的对话中。类似的讨论在这里