如何在内联CSS中编写a:visited?
我需要创建 HTML 电子邮件新闻通讯。所有样式都应该是内联的。 (根据 - http://www.campaignmonitor.com/css/ 并非所有电子邮件客户端都能识别 HEAD 标签中的 STYLE 标签。但他们都更喜欢内联样式。)
我的问题: 设计师想要深色背景色+白色链接,所以我使用 -
<a href="http://www.mySite.com" target="_blank">
<span style="color: #ffffff;" >ici</span>
</a>
但默认的“访问颜色”是深色的。
还有另一种方法可以改变“访问的颜色”吗?
谢谢,
阿塔拉。
PS我还尝试了解密的BODY链接,vlink属性。没有用。
Related Topic: How to write a:hover in inline CSS?
I need to create an HTML Email News Letters. All styles should be inline. (According to –
http://www.campaignmonitor.com/css/
Not all email clients recognize STYLE tag with in the HEAD tag. but they all prefer inline styles.)
My Problem:
The designer wants a dark background color + white links, so I use -
<a href="http://www.mySite.com" target="_blank">
<span style="color: #ffffff;" >ici</span>
</a>
but the default "visited color" is dark.
Is there another way to change the "visited color" ?
Thanks,
Atara.
P.S. I also tried the decrypted BODY link, vlink attributes. did not work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
首先,祝你好运! HTML 电子邮件牢牢停留在 1996 年的技术水平。
如果您实际上不需要单独的“访问”颜色,可以尝试的一件事是在跨度上添加 !important。
例如,您的邮件客户端可能在其样式表中具有类似以下内容:
在这种情况下,它将覆盖您的内联样式。
因此,尝试将您的跨度更改为:
以再次覆盖它。
Chrome 中的快速测试表明
a:visited * { ... !important}
确实覆盖了内联样式,但将!important
添加回跨度效果很好。2017 更新
CampaignMonitor CSS 指南现在似乎建议在头部使用
元素,而不是内联所有样式。根据其他答案,这似乎提供了与最新版本的 Outlook 的最佳兼容性。
First off, good luck! HTML email is stuck firmly at 1996 tech levels.
One thing to attempt if you don't actually need a separate "visited" colour is to add an !important on the span.
For example, your mail client may have something like this in their style sheet:
In which case that will override your inline style.
So, try changing your span to:
to override it back again.
A quick test in Chrome shows that the
a:visited * { ... !important}
does override the inline style, but adding the!important
back to the span works fine.2017 Update
The CampaignMonitor CSS guide now seems to recommend using a
<style>
element in the head, rather than inlining all styles. Based on other answers this seems to provide the best compatibility with recent version of Outlook.我在 2016 年尝试了这里描述的所有想法(使用 Outlook 2010 及更高版本),但没有一个对我有用。但我使用此解决方案取得了成功: https://jamesnorthard.com/ Outlook-change-visited-link-color-in-email/
他在锚标记内使用了强标记(代码来自他的博客文章):
我的链接
它甚至修复了使用 Gmail 转发电子邮件时链接颜色变化的问题。
希望对其他人有帮助!
I tried all that ideas described here in 2016 (with Outlook 2010 and up), none of them worked for me. But I had success using this solution: https://jamesnorthard.com/outlook-changing-visited-link-color-in-email/
He uses the strong tag inside the anchor tag (code from his blog post):
<a href="#" style="color:#333399;"><strong style="font-weight:normal;">My Link</strong></a>
It even fixes the problem of a changing link color when forwarding an email with Gmail.
Hope that helps anyone else!
为什么不尝试在
标记内设置
style
属性并完全删除呢?
内联执行此操作应覆盖
:visited
属性。像这样:
注意: 为了安全起见,您可以在其中添加
!important
属性以进一步备份它。我认为这是最好的做法,也是最干净的方法。
Why not try setting the
style
attribute inside the<a>
tag and removing the<span>
altogether?Doing that inline should overwrite the
:visited
property.Like this:
Note: And just to be safe you can add the
!important
property in there to further back it up.I think this is the best practice and the cleanest way to do this.
这是相当古老的线程,但认为它对某人有用。 使用普通的旧内容之外,在 Outlook 2013 中没有其他任何方法对我有用
除了在 body 中
This is pretty old thread but thought it would be useful to somebody. Nothing else worked for me in outlook 2013 except using the plain old
within the body
一个快速但肮脏的解决方案:在 HTML 电子邮件新闻信函的 正文 中添加 vlink = "yourcolor"(与 !DOCTYPE HTML PUBLIC "-//W3C//DTD 配合使用) HTML 4.01 过渡 //EN"
“http://www.w3.org/TR/html4/loose.dtd”)
a quick and dirty solution : add vlink = "yourcolor" in the body of your HTML Email News Letter (works with !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd")