亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

jquery重新播放css動(dòng)畫(huà)所遇問(wèn)題解決

 更新時(shí)間:2013年08月21日 19:14:27   作者:  
做css動(dòng)畫(huà),遇到需要用腳本重新播放動(dòng)畫(huà)的情況,下面與大家分享下,感興趣的朋友可以參考下,希望對(duì)大家有所幫助
最近在做css動(dòng)畫(huà),遇到需要用腳本重新播放動(dòng)畫(huà)的情況。例如:

css動(dòng)畫(huà)代碼
復(fù)制代碼 代碼如下:

.seed_txt_out .seed_txt h2 {
animation-name: seed-h2;
animation-duration: 2s;
animation-timing-function: ease;
animation-delay: 0s;
animation-iteration-count: 1;
animation-direction: alternate;
animation-play-state: running;
position: relative;
top: 10px;
}
@keyframes seed-h2
{
from {top: -120px;}
to {top: 10px;}
}

jquery調(diào)用播放
復(fù)制代碼 代碼如下:

$(".seed_txt_out").children("div").removeClass("seed_txt");
$(".seed_txt_out").children("div").addClass("seed_txt");

這時(shí)候,會(huì)發(fā)現(xiàn),第一次顯示,動(dòng)畫(huà)會(huì)正確播放,但是,第二次的時(shí)候,動(dòng)畫(huà)就不會(huì)播放了。

后來(lái)上網(wǎng)查了一下,解決辦法很簡(jiǎn)單,復(fù)制一個(gè)元素,把原來(lái)的去掉,在新的上面添加式樣就可以了。
復(fù)制代碼 代碼如下:

$(opts.txt).children("div").removeClass("seed_txt");
temp = $(opts.txt).children("div:eq(" + $(this).parent("ul").children("li").index(this) + ")");
newDiv = temp.clone(true);
temp.after(newDiv);
temp.remove();
newDiv.addClass("seed_txt");

這里有個(gè)鏈接,老外解決的辦法。還說(shuō)了其它情況。遇到類(lèi)似問(wèn)題的朋友可以參考下,當(dāng)然,是英文的。
http://css-tricks.com/restart-css-animation/

相關(guān)文章

最新評(píng)論