如何在悬停时更改按钮的颜色?

get*_*way 20 css button hover

我需要在悬停时更改按钮的颜色.

这是我的解决方案,但它不起作用.

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;
}
Run Code Online (Sandbox Code Playgroud)

Mat*_*chu 38

a.button a:hover意思是"正在悬停的链接是与该类链接的子节点button".

转而去a.button:hover.


Bru*_*oLM 13

似乎您的选择器是错误的,请尝试使用:

a.button:hover{
     background: #383;
}
Run Code Online (Sandbox Code Playgroud)

你的代码

a.button a:hover
Run Code Online (Sandbox Code Playgroud)

意味着它将使用类按钮搜索a内部元素a.