CSS HTML 电子邮件中的字体颜色 - Gmail

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

Font Color in HTML Email - Gmail

cssgmailhtml-email

提问by Kevin_TA

I know that I have to use inline CSS to style anything in an HTML email, but I am noticing an odd override that is occuring in gmail. I am trying to change the color of the text in a table row:

我知道我必须使用内联 CSS 为 HTML 电子邮件中的任何内容设置样式,但我注意到 gmail 中发生了奇怪的覆盖。我正在尝试更改表格行中文本的颜色:

<tr style='color: #000; font-size: 14px; font-family: Verdana, serif;'>

but when I open this email in gmail, the font-family and black color is being overwrote by gmail stylings. I'm seeing this via Firebug:

但是当我在 gmail 中打开这封电子邮件时,字体系列和黑色被 gmail 样式覆盖。我通过 Firebug 看到这个:

enter image description here

在此处输入图片说明

That purple color is being used instead of the black I want, and the font family is defaulting to arial,sans-serif. Does anyone know of a way to safely override the styling that gmail is forcing on me?

使用的是紫色而不是我想要的黑色,字体系列默认为 arial、sans-serif。有谁知道一种方法可以安全地覆盖 gmail 强加给我的样式?

UPDATE

更新

I changed the color to a non-black color, i.e. #212a2c and the color changed correctly, but the font-family is still stuck on arial.

我将颜色更改为非黑色,即 #212a2c 并且颜色更改正确,但字体系列仍然停留在 arial 上。

采纳答案by colonelclick

It looks like you are styling the TR but gmail is over riding it with a style to the TD. When a TD and a TR conflict, the TD will win because it is the most immediate container...the closest match as per css3 rules. I think if you use inline style on your TD you will be able to over ride it.

看起来您正在为 TR 设计样式,但 gmail 以一种与 TD 相匹配的样式超越了它。当 TD 和 TR 冲突时,TD 将获胜,因为它是最直接的容器...根据 css3 规则最接近的匹配。我认为如果您在 TD 上使用内联样式,您将能够超越它。

回答by Liz Long

From experience I have found the safest thing to do with color codes is always to use the 6 number code - I had a similar problem once and it was fixed simply by changing the color code from 3 digits to 6 - it doesn't take any time at all to type 3 extra numbers after all :)

根据经验,我发现使用颜色代码最安全的方法始终是使用 6 数字代码 - 我曾经遇到过类似的问题,只需将颜色代码从 3 位数更改为 6 即可解决 - 它不需要任何毕竟有时间输入 3 个额外的数字:)

回答by Bidstrup

  1. Dont use styles on <tr>, do it on <td>or a <span>around the text.
  2. It dosnt matter if you write #000, #000000 or Black as a color :)
  1. 不要在 上使用样式<tr>,在文本上<td><span>周围使用样式。
  2. 如果您将 #000、#000000 或 Black 写为颜色,则无关紧要:)

回答by crmpicco

GMail will change your links from black (#000000) to the default blue, presumably as an anti-spamming feature.

GMail 会将您的链接从黑色 (#000000) 更改为默认的蓝色,大概是作为一种反垃圾邮件功能。

To get around this, just change the color of the font to (#000001), e.g.

要解决这个问题,只需将字体的颜色更改为 (#000001),例如

<a href="#" style="color: #000001;">Click HERE</a>

回答by Chess Byte

"It dosnt matter if you write #000, #000000 or Black as a color :)"

“如果您将#000、#000000 或黑色写为颜色,这并不重要:)”

Yes it does, sometimes emails render 3 hexadecimal colours in a slightly different way. As a rule of thumb, it's best to stick with 6 for compatibility.

是的,有时电子邮件会以稍微不同的方式呈现 3 种十六进制颜色。根据经验,为了兼容性最好坚持使用 6。