开发者

ASP.NET button does not have hover state?

I checked the link at开发者_如何学C Asp Button hover and CSS but to my frustration, I still couldn't find a solution to apply CSS to the hover state of my ASP.NET button.

My button is declared like so:

    <asp:Button ID="btnRegister" runat="server" 
                 onclick="btnRegister_Click" CssClass="btnRegister"/>

My CSS for the button is:

.btnRegister {
    background-color:#FFF;
    color:#000;
}
.btnRegister : hover{
    border:solid 2px #000;
}

.btnRegister : active{
    background-color:#000;
    color:#FFF;
}

When I inspected the button in FF and IE, I saw the styling is only done on the button, not on the button when hovered.

Furthermore, I have a skin file applied to the page which holds the button but it is applied to other controls, not the button.

Anyone got any ideas on how to access the hover state of the button?


take out the extra blank spaces between the class name and the pseudo-state:

.btnRegister {
background-color:#FFF;
color:#000;
}
.btnRegister:hover{
border:solid 2px #000;
}

.btnRegister:active{
background-color:#000;
color:#FFF;
}


Hey, just remove the space before and after the 'hover' and 'active', and you get it.

.btnRegister:hover
.btnRegister:active


jQuery

$("button").hover(
  function () {
    $(this).css("your style");
  }, 
  function () {
    $(this).css("origin style");
  }
);

Hope this can help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜