我有一个带有单一样式按钮的简单测试页面。当您将鼠标悬停在按钮上时,我使用 a:hover 。但是,当您单击按钮时,a:hover 样式将保留,直到我单击其他内容。我该如何解决这个问题以及为什么会发生这种情况?
谢谢, 杆。
<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;
}
最佳答案
正是 a:focus
使它看起来像是激活了 a:hover
规则。 a:focus
匹配任何获得焦点的链接。当您单击链接时,该链接将成为焦点。
删除a:focus
规则就应该没问题了。
关于jquery - 点击后CSS样式仍然保留,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3053649/