2012-06-08 66 views
1

我正在尋找將一個默認類添加到一堆鏈接。因此,而不是向一組鏈接添加默認類

<a href=1 class=text1>1</a> 
<a href=2 class=text1>2</a> 
<a href=3 class=text1>3</a> 
<a href=4 class=text1>4</a> 
<a href=5 class=text1>5</a> 
<a href=6 class=text1>6</a> 
<a href=7 class=text1>7</a> 

我想做

<span class=text1> 
<a href=1 >2</a> 
<a href=2 >3</a> 
<a href=3 >4</a> 
<a href=4 >5</a> 
<a href=5 >6</a> 
<a href=6 >7</a> 
<a href=7 >8</a> 
</span> 

在文本1類是一樣的東西:

a.text1:link { color: white; text-decoration: underline ;} 
a.text1:active { color: white; text-decoration: underline ;} 
a.text1:visited { color: white; text-decoration: underline ;} 
a.text1:hover { color: white; text-decoration: underline ; } 

第二個選項似乎但是並沒有工作。我是愚蠢的嗎?還是有什麼辦法可以像這樣在一個小組中製作一堆鏈接?

回答

1

只需使用:

span.text1 a:link { 
    /* css */ 
} 

或者,如果必要的話,只選擇一級後裔, '立刻' 孩子:

span.text1 > a:link { 
    /* css */ 
} 
3

用途:

span.text1 a:link { color: white; text-decoration: underline ;} 
span.text1 a:active { color: white; text-decoration: underline ;} 
span.text1 a:visited { color: white; text-decoration: underline ;} 
span.text1 a:hover { color: white; text-decoration: underline ; } 
1

它不這樣工作。 試試這個

span.text1 a:link { color: white; text-decoration: underline ;} 
span.text1 a:active { color: white; text-decoration: underline ;} 
span.text1 a:visited { color: white; text-decoration: underline ;} 
span.text1 a:hover { color: white; text-decoration: underline ; }