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

问题描述 投票:0回答:3

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

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

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个回答
52
投票

a.button a:hover
表示“悬停在其上的链接是具有
button
类的链接的子级”。

a.button:hover


22
投票

看来您的选择器是错误的,请尝试使用:

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

这将在具有

:hover
类的
a
元素上查找
button
,例如:

<a class="button">Hover on me!</a>

代替您的代码:

a.button a:hover

这意味着它将搜索

:hover
元素
inside
a
a
class="button"
,例如:

<a class="button">
  <a>Hover on me!</a>
</a>

3
投票
a.button:hover{
    background: #383;  }

对我有用,但就我而言

#buttonClick:hover {
background-color:green;  }
© www.soinside.com 2019 - 2024. All rights reserved.