久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

css3動畫 - 如何重新運(yùn)行css3的動畫?

瀏覽:128日期:2023-07-31 16:38:21

問題描述

如何通過一個事件(hover,click..)觸發(fā)css3動畫的重新執(zhí)行?在stackoverflow找到一個相關(guān)的問題,但是下面給出的答案也不起作用。

http://jsfiddle.net/arunpjohny/8WQcy/1/

這篇文章挺好的,介紹了重新運(yùn)行css3動畫的不同方法

animation必須是infinite,animation-play-state才有效。

restart用這種方法挺好:

// retrieve the elementelement = document.getElementById('logo');// reset the transition by...element.addEventListener('click', function(e) { e.preventDefault; // -> removing the class element.classList.remove('run-animation'); // -> triggering reflow /* The actual magic */ // without this it wouldn’t work. Try uncommenting the line and the transition won’t be retriggered. element.offsetWidth = element.offsetWidth; // -> and re-adding the class element.classList.add('run-animation');}, false);

問題解答

回答1:

解釋:http://www.w3school.com.cn/cssref/pr_animation-play-state.asp測試:http://www.w3school.com.cn/tiy/c.asp?f=css_animation-play-state&p=...

回答2:

$it.css(’-webkit-animation-play-state’, ’running’);

你這里的屬性名寫錯了

回答3:

我也在找怎么用事件重啟css3 animation動畫呢,可是我發(fā)現(xiàn)這個問題不知道是太簡單還是什么,在國內(nèi)根本就找不到答案,我只能硬著頭皮去stackoverflow去搜,很巧合的是我也找到了你的那篇文章,寫的很棒很詳細(xì),雖然英文不好,但獲益良多,我很納悶為什么看似簡單的問題卻根本百度不到,難道大家都沒遇到過嗎

回答4:

這個問題我也遇到過, 所幸還好容易解決. 給要動畫的dom元素上加個可控制的CSS。

js. 控制 $(’.animation’).removeClass(’active’).delay(10).queue(function(next){

$(this).addClass(’active’); next(); //讓下面的隊(duì)列函數(shù)得以執(zhí)行; 猜的 });回答5:

在IPHONE9.1上還是不行。 PC瀏覽器正常。有沒有解決辦法?

回答6:

為何不用animationend事件,這個也很好做兼容

el.addEventListener(’click’,function(){ this.classList.add(’active’); this.addEventListener(’animationend’,function(){this.classList.remove(’active’); });});

標(biāo)簽: CSS
相關(guān)文章:
主站蜘蛛池模板: 清徐县| 连州市| 迁安市| 洛南县| 宝鸡市| 宁德市| 奉节县| 合川市| 云霄县| 宿迁市| 手机| 宣武区| 桐梓县| 汕头市| 安溪县| 抚宁县| 福清市| 中宁县| 宜春市| 新宁县| 陵川县| 韶山市| 尼玛县| 绥棱县| 汉川市| 黄大仙区| 大宁县| 三门峡市| 临武县| 谷城县| 电白县| 湖口县| 临高县| 赫章县| 巫山县| 汶上县| 涿州市| 玉树县| 大英县| 定安县| 南京市|