2015-02-24 58 views
0

使用CSS的另一個問題。CSS顏色轉換不起作用:懸停

我希望頭部的背景顏色從懸停時(由於多個站點具有不同的顏色)當前轉換到另一個。

我做了一個CSS-transition-animation它,但它似乎並沒有工作。 我在做什麼錯?

 #header 
    { 
    background-color: #3cff9c; 
    float: left; 
    text-align: center; 
    width: 100%; 
    } 

    #header:hover 
    {   
    /*Animation*/ 
    -webkit-animation: colorChange_blue 1s; /* Safari, Chrome, Opera*/ 
    -moz-animation: colorChange_blue 1s; /*Firefox*/ 
    animation: colorChange_blue 1s; /*Standard*/ 

    /*Safari, Chrome, Opera*/ 
    @-webkit-keyframes colorChange_blue 
    { 
    from 
     {background-color;} 
    to 
     {background-color: #008c74;} 
    } 

    /*Firefox*/ 
    @-moz-keyframes colorChange_blue 
    { 
    from 
     {background-color: currentColor;} 
    to 
     {background-color: #008c74;} 
    } 

    /*Standard*/ 
    @keyframes colorChange_blue 
    { 
    from 
     {background-color: currentColor;} 
    to 
     {background-color: #008c74;} 
    } 
} 
+0

沒有ü錯過閉架中的#header:懸停? – 2015-02-24 09:14:42

+0

你使用'currentColor'或它的值#3cff9c在每個部分 – singhiskng 2015-02-24 09:16:25

+0

@matteo看起來不像它。從我所知道的情況來看,它完全在底部。 – 2015-02-24 09:16:45

回答

0

如何解決它沒有關鍵幀和標準懸停與轉換?

#header { 
 
    height: 50px; 
 
    width: 100px; 
 
    background-color: #3cff9c; 
 
    transition: background-color 1s; 
 
} 
 

 
#header:hover {   
 
    background-color: #008c74; 
 
}
<div id="header"></div>

+0

我是否仍然可以使用「currentColor」呢? – 2015-02-24 09:23:33

+0

好吧,你只需要定義'#header'中的通常顏色,並將其他顏色懸停在懸停語句 – MMachinegun 2015-02-24 09:24:46

+0

那麼沒有,因爲沒有理由...... – MMachinegun 2015-02-24 09:25:04