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

时间:2021-12-10 20:32:38

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;
}

3 个解决方案

#1


34  

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表示“正在悬停的链接是一个带有类按钮的链接的子节点”。

Go instead for a.button:hover.

转而去a.button:悬停。

#2


11  

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.

意味着它将在带有类按钮的内部搜索一个元素。

#3


0  

a.button:hover{
    background: #383;  }

works for me but in my case

对我而言,但在我的情况下

#buttonClick:hover {
background-color:green;  }

#1


34  

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表示“正在悬停的链接是一个带有类按钮的链接的子节点”。

Go instead for a.button:hover.

转而去a.button:悬停。

#2


11  

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.

意味着它将在带有类按钮的内部搜索一个元素。

#3


0  

a.button:hover{
    background: #383;  }

works for me but in my case

对我而言,但在我的情况下

#buttonClick:hover {
background-color:green;  }