2015-11-04 55 views
1

我想爲背景圖片設置動畫效果(從100%縮小到120%) 從100縮放到120可以正常工作。放大到120後,圖像自動設置爲100,並再次開始相同的過程。 我想放大它。 像這樣:從100到120和從120到100.這怎麼可能?animate:在CSS中縮放背景

.imageBlub{ 
    background: url('../Images/blub.jpg'); 
    background-size: 100% auto; 
    animation: animatedBackground 6s linear infinite; 

} 

@keyframes animatedBackground { 
    from { background-size: 100% auto; } 
    to { background-size: 120% auto;} 
} 

回答

4

我建議使用animation-direction: alternate;捐贈:

animation: animatedBackground 6s linear alternate infinite; 

此屬性值,顧名思義,交替動畫導演;首先「前進」(0至100%),然後「後退」(100%至0)。

參考文獻:

+1

這是一個輝煌的,是這種情況下,不是改變關鍵幀產生相反的效果更加簡單。 – Harry

+0

是的。謝謝 !!! –

+0

謝謝你們兩位;米納斯,我很樂意幫助! –

-1
@keyframes animatedBackground { 
    from { background-size: 0% auto; } 
    to { background-size: 100% auto;} 
} 

試試這個......