2010-06-16 67 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规则,它应该没问题。