javascript 使用css更改鼠标悬停时asp.net按钮的颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18665081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change color of an asp.net button on mouse hover using css
提问by CodeNinja
I have a button :
我有一个按钮:
<div class="HeaderBarThreshold">
<asp:LinkButton ID="SetThreshold" OnClick="btnSetThreshold_Click" runat="server">Threshold</asp:LinkButton>
</div>
I am trying to change the color of the button on mouse hover :
我正在尝试更改鼠标悬停时按钮的颜色:
Here is my css :
这是我的 css:
.HeaderBarThreshold
{
padding-left: 10px;
font-weight: bold;
}
.HeaderBarThreshold:hover
{
color: Red;
}
It doesnt work somehow. Please let me know.
它以某种方式不起作用。请告诉我。
采纳答案by Milad Hosseinpanahi
just try this
试试这个
.HeaderBarThreshold:hover a
{
color: Red !important; // !important may not be necessary
}
回答by maccettura
Try using the CssClass Property of ASP.NET controls. This will directly point the LinkButton itself to the CSS class, instead of having to use the div tag. For example:
尝试使用 ASP.NET 控件的 CssClass 属性。这将直接将 LinkButton 本身指向 CSS 类,而不必使用 div 标签。例如:
<asp:LinkButton ID="SetThreshold" OnClick="btnSetThreshold_Click" runat="server" CssClass="HeaderBarThreshold">Threshold</asp:LinkButton>
回答by Hyman Marchetti
Add the CSS class attribute to your web control
将 CSS 类属性添加到您的 Web 控件
<asp:LinkButton CSSClass="HeaderBarThreshold" ID="SetThreshold" OnClick="btnSetThreshold_Click" runat="server">Threshold</asp:LinkButton>
Also your CSS is wrong anyway because you don't have anything assigned to class "HeaderBarThreshold".
无论如何,您的 CSS 也是错误的,因为您没有分配给“HeaderBarThreshold”类的任何内容。
回答by Irfan TahirKheli
try this thing:
试试这个:
.HeaderBarThreshold a:hover
{
color: Red;
}
回答by Nikhil Gupta
.upda_link {
font-size: 15px !important;
color: white;
font-weight: bolder;
}
.upda_link:hover {
text-decoration: none;
color: white;
}
<asp:LinkButton ID="LinkButton1" runat="server" Text="Update" CssClass="upda_link" CausesValidation="false">
</asp:LinkButton>
回答by Travis
Here is a fiddle http://jsfiddle.net/zpfw7/
这是一个小提琴http://jsfiddle.net/zpfw7/
.HeaderBarThreshold
{
padding-left: 10px;
font-weight: bold;
width:300px;
height:30px;
border:1px solid #000;
text-align:center;
}
.HeaderBarThreshold:hover
{
color: Red;
background:blue;
}