2016-03-03 33 views
1

我有需要在窗口加載到「反彈」上下不斷,像在本頁面頂部的滾動圖像的圖像:http://www.complex.com/pop-culture/zendaya-interview-2015-cover-story如何使連續的圖像反彈的jQuery

我不想使用jQuery ui。我需要圖像來完成一個動畫(動畫向下20px),然後在循環中執行下一個(動畫向上20px)。我似乎無法弄清楚1)兩步動畫和2)循環動畫。

+0

可能要試試這個:https://daneden.github.io/animate.css/ –

回答

1

嘗試使用CSS這樣的:

@keyframes example { 
    0% {margin-top: 0px;} 
    50% {margin-top: 20px;} 
    100% {margin-top: 0px;} 
} 

div{ 
    display: inline-block; 
    border: 1px solid black; 
    animation-name: example; 
    animation-duration: 2s; 
    animation-iteration-count: infinite; 
} 

JFiddle

+1

動畫更流暢,如果你使用translateY - https://jsfiddle.net/e5eamncx/ - 投了你的A – Tasos

+0

謝謝@Tasos,你說得對translateY()更順暢。 –

+0

啊!那就是訣竅。非常感謝! – Katie