2011-01-06 61 views
0

我想改变一个链接的颜色使用CSS,但只有一个页面的一部分。 但问题是,它不工作。只有一个部分的Css链接

我想改变文本的下表中的链接颜色:

<table width="100%" class="icons"> 
    <tr class="icons"> 
    <td class="icons"><a href="http://www.example.com/"> 
    <img src="http://www.example.com/2.png" /> 
    TEXT 
    </a></td> 
    </tr> 
</table> 

这是CSS:

.icons{ 
    font-size:24px; 
    margin-bottom:40px; 
} 

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

我甚至尝试<span class="icons">TEXT</span>并没有任何工作。

非常感谢!

回答

4

您需要链接伪类适用于<a>,而不是<td class="icons">

.icons a:link {text-decoration: none; color: red;} 
.icons a:visited {text-decoration: none; color: red;} 
.icons a:active {text-decoration: none; color: red;} 
.icons a:hover {text-decoration: underline; color: blue;} 
+1

+1的一个很好的答案。鉴于上述情况,还值得指出的是,您只需指定class =“图标”一次;它不需要在所有三个元素(表,tr和td)上。它可以在任何一个上面工作;选择最符合您要求的那个。 – Spudley 2011-01-06 11:31:09

相关问题