How can I change a button's color on hover?

2019-01-06 20:01发布

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

标签: css button hover
3条回答
我想做一个坏孩纸
2楼-- · 2019-01-06 20:17

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.

查看更多
你好瞎i
3楼-- · 2019-01-06 20:26
a.button:hover{
    background: #383;  }

works for me but in my case

#buttonClick:hover {
background-color:green;  }
查看更多
做个烂人
4楼-- · 2019-01-06 20:30

a.button a:hover means "a link that's being hovered over that is a child of a link with the class button".

Go instead for a.button:hover.

查看更多
登录 后发表回答