2012-05-03 76 views
0
<body> 
    <acctctrls> 
     <a href="http://www.some-link.com/">Link inside acctctrls tag</a> 
    </acctctrls> 
    <a href="http://www.some-link.com/">Link outside acctctrls tag</a> 
</body> 

我想acctctrls標籤內的<一個>標籤遵循這個CSS:如何通過周圍的標籤,以排除標籤

a 
{ 
    color: #C20000; 
    font-size: 12px; 
    font-weight:600; 
    text-align:center; 
} 

我想acctctrls標籤外<一個>標籤按照這個CSS:

a 
{ 
    text-decoration: none; 
    font-style: normal; 
    color: #D0D0D0; 
} 
a:hover 
{ 
    text-decoration: none; 
    font-style: bold; 
    color: #EEEEEE; 
} 
+0

你有這個標籤的任何理由?爲什麼不只是讓這些標籤有一些指定'類' – kei

回答

0

試試這個:

acctctrls a { 
    color: #C20000; 
    font-size: 12px; 
    font-weight:600; 
    text-align:center; 
} 
+0

謝謝你太多了! – Timberwolf

+0

...我無法點擊「接受」作爲答案按鈕......這很愚蠢。 – Timberwolf

0

做了嘗試:

acctctrls a{ 
    color: #C20000; 
    font-size: 12px; 
    font-weight:600; 
    text-align:center; 
} 
+0

我做了,剛剛 – Timberwolf

+0

和...工作? :) –

0

更改樣式:

a 
{ 
    text-decoration: none; 
    font-style: normal; 
    color: #D0D0D0; 
} 
a:hover 
{ 
    text-decoration: none; 
    font-style: bold; 
    color: #EEEEEE; 
} 

acctctrls a 
{ 
    color: #C20000; 
    font-size: 12px; 
    font-weight:600; 
    text-align:center; 
} 

CSS Selectors 當您提供一個以上的標籤名稱,然後通過默認的CSS將執行的最後一個標籤的造型時,它是標籤的後裔在此之前。

我知道這個鏈接是針對CSS2的,但同樣也適用於CSS3。

0

留下第二個a和a:hover規則集,並增加第一個獲取<acctctrls />中鏈接的特殊性。

acctctrls a { 
    color: #C20000; 
    font-size: 12px; 
    font-weight:600; 
    text-align:center; 
} 

但是,正如kei所說,使用帶有class或id的標準元素可能會更好。否則,您需要使用JavaScript shiv(例如,document.createElement('acctctrls'))來爲IE識別您的CSS元素。