2013-03-17 38 views
0

我似乎無法讓我的按鈕更改CSS3轉換顏色。我已經成功地在標籤上使用了相同的代碼,但沒有這個按鈕。按鈕上的CSS3顏色轉換

下面的代碼:

.button { 
    position:absolute; 
    width: 135px; 
    height: 46px; 
    background-color: #ef6529; 
    text-decoration: none; 
    border-radius: 4px; 
    -moz-border-radius: 4px; 
    border: 1px solid #c33b00; 
    box-shadow: 0px 4px 0px #af5a5a; 
    -moz-box-shadow: 0px 4px 0px #af5a5a; 
    -webkit-box-shadow: 0px 4px 0px #af5a5a; 
    -webkit-transition:color 1s ease-in; 
    -moz-transition:color 1s ease-in; 
    -o-transition:color 1s ease-in; 
    transition:color 1s ease-in; 
} 

.button:hover { 
    width: 135px; 
    height: 46px; 
    background-color: #ff6726; 
    border-radius: 4px; 
    -moz-border-radius: 4px; 
    border: 1px solid #c33b00; 
    text-decoration: none; 
} 

和HTML:

<a href="#" class="button"> 
    <!--<h2>PUSH ME!</h2>--> 
</a> 

乾杯!

+0

你能發佈你的html嗎?將有助於看到標記 – 2013-03-17 15:31:26

+0

對不起,忘了! – 2013-03-17 15:54:14

回答

0

您還沒有指定按鈕的顏色。我認爲你想過渡背景顏色insted。只需將transition:color 1s ease-in;更改爲transition: background-color 1s ease-in;即可。

+0

啊,我明白了!這就是爲什麼它在其他元素上工作的原因,因爲我只是更改'color'屬性。指定'background-color'工作。謝謝! – 2013-03-17 16:09:54