2010-10-10 77 views
15

我需要更改懸停時按鈕的顏色。如何在懸停時更改按鈕的顏色?

這是我的解決方案,但它不起作用。

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

回答

32

a.button a:hover表示「這是正在上空盤旋,一個環節是與類button鏈接的孩子」。

改爲a.button:hover

10

看來你的選擇是錯誤的,請嘗試使用:

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

您的代碼

a.button a:hover 

意味着它會搜索裏面a帶班按鈕的a元素。

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

對我的作品,但我的情況

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