2011-01-06 13 views
0

Ich versuche, die Farben eines Links mit CSS zu ändern, aber nur für einen Abschnitt einer Seite. Das Problem ist, dass es nicht funktioniert.Css Link nur für einen Abschnitt

Ich möchte den Link Farbe des Textes in der folgenden Tabelle ändern:

<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> 

Und das ist die 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;} 

Ich habe sogar versucht <span class="icons">TEXT</span> und das hat nicht funktioniert.

Vielen Dank!

Antwort

4

Sie müssen die Link-Pseudo-Klassen zum <a>, nicht die <td class="icons"> anzuwenden:

.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 für eine gute Antwort. Angesichts der oben genannten, ist es auch erwähnenswert, dass Sie nur die class = "icons" einmal angeben müssen; Es muss nicht auf allen drei Elementen (Tabelle, tr und td) sein. Es wird an jedem von ihnen funktionieren; Wählen Sie diejenige, die Ihren Anforderungen am besten entspricht. – Spudley

Verwandte Themen