css3的animation动画结束事件与兼容性写法,transition结束事件类似

本文介绍了一种使用jQuery实现CSS3动画和过渡效果的方法,并提供了兼容多种浏览器的回调函数示例代码。同时,还展示了如何定义动画的CSS样式,包括不同阶段背景图片的变化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

好几次用了,不好找,这次总结下来以后就方便了
//  Animation结束回调函数,兼容写法
$('.btn').addClass('animate-bg').on("animationend webkitAnimationEnd oAnimationEnd oanimationend MSAnimationEnd",function(){
		console.log(1)
 });    

 

//  transition结束回调函数,兼容写法
    	$('.btn').addClass('animate-bg').on("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd",function(){
		        console.log(1)
	});

对了,还有动画css写法,一起留着吧,有用!

        .animate-bg{
    		-webkit-animation:ani-bg 1.2s;
    	    	-moz-animation:ani-bg 1.2s;
    		animation: ani-bg 1.2s;
    		background: url(img/1.png) no-repeat;
			background-size:100% 100%;
    	}
    	@keyframes ani-bg{
    		0%{
    			opacity: 1;
    			background: url(img/1.png) no-repeat;
    			background-size:100% 100%;
    		}
    		25%{
    			background: url(img/2.png) no-repeat;
    			background-size:100% 100%;
    		}
    		50%{
    			background: url(img/3.png) no-repeat;
    			background-size:100% 100%;
    		}
    		75%{
    			background: url(img/4.png) no-repeat;
    			background-size:100% 100%;
    		}
    		100%{
    			opacity: 0.5;
    			background: url(img/1.png) no-repeat;
    			background-size:100% 100%;
    		}
    	}

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值