2010-06-16 156 views
1

我有一個簡單的測試頁面,只有一個樣式的按鈕。當您將鼠標懸停在按鈕上時,我使用的是:懸停。但是,當您單擊該按鈕時,a:hover樣式將保留,直到我點擊其他東西。我將如何解決這個問題,爲什麼會發生這種情況?點擊後仍保留css樣式

謝謝, 杆。

<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server"> 

    <% using (Ajax.BeginForm(new AjaxOptions { })) 
     { %> 
    <div id="detailActions"> 
     <a href="#">Delete User</a> 
    </div> 
    <% } %> 
</asp:Content> 

我的CSS:

#detailActions 
{ 
    margin-bottom: 7px; 
    padding: 3px 0px 5px 0px; 
} 
#detailActions 
{ 
    padding: 1px 7px 1px 7px; 
    margin: 0px 5px 0px 0px; 
    border: solid 1px gray; 
    background-color: #ADD8E6; 
    cursor: pointer; 
    width: auto !important; 
    font-weight: bold; 
    text-decoration: none; 
    color: #003366; 
    font-size: 1.2em; 
} 

#detailActions a:hover, #detailActions a:active, #detailActions a:focus 
{ 
    color: White; 
    background-color: #00008B; 
} 

回答

3

這是這使得它看起來像a:hover規則被激活a:focusa:focus匹配任何專注的鏈接。當你點擊一個鏈接時,它變得專注。

刪除a:focus規則,它應該沒問題。