CSS 如何在悬停时更改按钮的颜色?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3898781/
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
How can I change a button's color on hover?
提问by getaway
I need to change the color of a button on hover.
我需要在悬停时更改按钮的颜色。
Here is my solution, but it doesn't work.
这是我的解决方案,但它不起作用。
a.button {
display: -moz-inline-stack;
display: inline-block;
width: 391px;
height: 62px;
background: url("img/btncolor.png") no-repeat;
line-height: 62px;
vertical-align: text-middle;
text-align: center;
color: #ebe6eb;
font-family: Zenhei;
font-size: 39px;
font-weight: normal;
font-style: normal;
text-shadow: #222222 1px 1px 0;
}
a.button a:hover{
background: #383;
}
回答by Matchu
a.button a:hover
means "a link that's being hovered over that is a child of a link with the class button
".
a.button a:hover
表示“悬停在该链接上的链接是该类链接的子链接button
”。
Go instead for a.button:hover
.
改为a.button:hover
.
回答by BrunoLM
Seems your selector is wrong, try using:
似乎您的选择器有误,请尝试使用:
a.button:hover{
background: #383;
}
Your code
你的代码
a.button a:hover
Means it is going to search for an a
element inside a
with class button.
意味着它将使用类按钮搜索a
内部元素a
。
回答by Penh
a.button:hover{
background: #383; }
works for me but in my case
对我有用,但就我而言
#buttonClick:hover {
background-color:green; }