html - 同一 HTML 页面上的不同颜色链接

标签 html css colors hyperlink

您好,我想在同一页面上设置不同颜色的链接。我想要一些链接是蓝色的,一些链接是黑色的。我是 html 和 CSS 的新手,所以提前谢谢你!

-斯宾塞

最佳答案

CSS:

a.class1 {color:red;}
a.class1:link  {text-decoration: none; color: red;}
a.class1:visited {text-decoration: none; color: red;}
a.class1:hover {text-decoration: underline; color: red;}
a.class1:active {text-decoration: none; color: red;}


a.class2 {color:blue;}
a.class2:link {text-decoration: none; color: blue;}
a.class2:visited {text-decoration: none; color: blue;}
a.class2:hover {text-decoration: underline; color: blue;}
a.class2:active {text-decoration: none; color: blue;}

HTML:

<a href="http://www.google.com" class="class1">Google</a>
<a href="http://stackoverflow.com" class="class2">Stackoverflow</a>

演示: https://jsfiddle.net/3L4xguj7/

2021 年 5 月 16 日更新: 更新链接

关于html - 同一 HTML 页面上的不同颜色链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50019190/

相关文章:

colors - Neo4j 中的着色节点取决于属性

html - 设置具有固定宽度单元格的网格样式

php - 用户可以使用直接链接访问 protected 页面。如何创建重定向?

android - 在样式中使用颜色引用

jquery - .slideUp 仅适用于移动设备

css - 我的网站仅适用于 safari。即,chrome 和 firefox 无法识别我的 css

python - 如何使用curses 和Python 设置窗口背景颜色?

jquery - 无法在 div 内 float 跨度

javascript - 不同功能的 Mocha 测试用例

jquery - 从外部链接到 Bootstrap 选项卡 - 如何将选项卡设置为 "active"?