2013-04-12 29 views
-1

我有這些樣式爲全球所有我的鏈接。我無法覆蓋同一頁面上的div中的鏈接樣式。我剛剛發現了CSS中的錯誤,或者我忽略了一些東西?

a, a:visited{ 
    outline: 0; 
    cursor: pointer; 
    color: inherit; 
    text-decoration: none; 
} 

a:hover{ 
    text-decoration: underline; 
} 

現在我要重寫錨鏈接樣式,以將其顏色改爲白色懸停,但只有在多類這樣一個看不見的通知容器的一個div ...

<div class="unseen notificationContainer">      
    <a href="profile?customerId=1365764036258"> 
     <strong>robert</strong> 
    </a> 
    sent you a friend request 
    <a href="friend_request?type=accept&amp;notificationId=1365764054463"> 
     Accept 
    </a> 
    <a href="friend_request?type=reject&amp;notificationId=1365764054463"> 
     Reject 
    </a>   
</div> 

所以我添加下面我CSS

.unseen{ 
    background: #09f; 
    color: #fff; 
} 

.unseen a :hover{ 
    color: #fff; 
    text-decoration: underline; 
} 

頁面加載徘徊第一個鏈接讓改變其顏色爲白色,但其他三個取背景的顏色爲藍色。過去一個小時我一直在這裏,而不是隻是令人煩惱。通知容器的樣式如下

.notificationContainer{ 
    width: 390px; 
    float: left; 
    border-bottom: solid 1px #eee; 
    padding: 5px; 
} 

在此先感謝。

+2

考慮編輯問題的標題更具體的實際問題 – davidb

回答

7

CSS不可能有錯誤,只有瀏覽器可以(除非你指的是CSS規範中的錯誤等)。

這就是說,這是你的代碼,而不是與瀏覽器中的錯誤:

.unseen a :hover{ 
    color: #fff; 
    text-decoration: underline; 
} 

a:hover之間的空間是指:hovera任何元素,就像.unseen a意味着a.unseen內的元素,所以這將不起作用。您需要刪除空間:

.unseen a:hover{ 
    color: #fff; 
    text-decoration: underline; 
} 
+0

謝謝你的快速回復,先生,我已經測試了一干淨的頁面,它的工作原理,但在原始頁面沒有。我必須檢查並看看有哪些其他規則可能導致這種情況。 – qualebs

0

不能確定你後是什麼 - 你的問題並沒有真正說清楚。如果我錯過了猜測,請原諒我。這有幫助嗎? (您可以針對多類元素)

<style> 
a, a:visited{ 
outline: 0; 
cursor: pointer; 
color: inherit; 
text-decoration: none; 
} 

a:hover{ 
    text-decoration: underline; 
} 

.unseen.notificationContainer a:hover 
{ 
    background: #09f; 
    color: #fff; 
    text-decoration: underline; 
} 
.notificationContainer 
{ 
    display: inline-block; 
    float: left; 
    border-bottom: solid 1px #eee; 
    padding: 5px; 
} 
</style> 

<div class="unseen notificationContainer">      
    <a href="profile?customerId=1365764036258"><strong>robert</strong></a> 
    sent you a friend request 
    <a href="friend_request?type=accept&amp;notificationId=1365764054463">Accept</a> 
    <a href="friend_request?type=reject&amp;notificationId=1365764054463">Reject</a>   
</div> 
+0

如果通知未被讀取,那麼'unseen'類動態地添加到'notificationContainer' div。我想要的是未讀通知具有藍色背景。但由於懸停上的鏈接變成了藍色,因此藍色背景使它們不可見,所以我希望它們在懸停時變成白色。 – qualebs

相關問題