CSS:根据当前颜色更改字体颜色

时间:2021-09-24 19:38:54

I'm trying to find css that will allow me to change the color of text depending on the current color of the text.

我正在尝试找到css,这将允许我根据文本的当前颜色更改文本的颜色。

Here is the HTML (not HTML5) I'm trying to change:

这是我想要改变的HTML(不是HTML5):

    <a href="link"><font color="green">2</font></a>
    <a href="link"><font color="red">3</font></a>
    <a href="link"><font color="red">2</font></a>
    <a href="link"><font color="green">3</font></a>
    <a href="link"><font color="red">2</font></a>
    <a href="link"><font color="green">3</font></a>

What I want to do is change to red links to yellow and the green links to blue. I can't use javascript or change the HTML code. I'm only allowed to add CSS to change styles. Is there a way to do this using only CSS.

我想要做的是将红色链接更改为黄色,将绿色链接更改为蓝色。我不能使用javascript或更改HTML代码。我只允许添加CSS来改变样式。有没有办法只使用CSS来做到这一点。

1 个解决方案

#1


17  

a font[color="red"] { color: yellow; }
a font[color="green"] { color: blue; }

http://jsfiddle.net/3zLfb/

http://jsfiddle.net/3zLfb/

#1


17  

a font[color="red"] { color: yellow; }
a font[color="green"] { color: blue; }

http://jsfiddle.net/3zLfb/

http://jsfiddle.net/3zLfb/