jquery 动画

简介: jquery动画有意思的地方见效果图: 思想:将图片设置分割div的背景图片,控制div的属性,可以现实有趣的滤镜效果,本例中展示了一种,感兴趣的朋友可以尝试其他滤镜的实现。本例其余动画部分,主要是利用jquery中提供animate和delay实现。

jquery动画
有意思的地方见效果图:



思想:
将图片设置分割div的背景图片,控制div的属性,可以现实有趣的滤镜效果,本例中展示了一种,感兴趣的朋友可以尝试其他滤镜的实现。

本例其余动画部分,主要是利用jquery中提供animate和delay实现。
animate:这个函数的关键在于指定动画形式及结果样式属性对象。这个对象中每个属性都表示一个可以变化的样式属性。
delay:设置一个延时来推迟执行队列中之后的项目。


实例效果:

<!DOCTYPE html> <html> <head> <title>jquery 动画</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript" src="http://files.cnblogs.com/kuikui/jquery.js"></script> <style type="text/css"> *{margin: 0px;padding: 0px;} #test{width:300px; height: 300px; position: relative; margin: 20px auto 0px;} </style> </head> <body> <div id="test"> <img alt="" width="300" height="300" src="http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_test1.jpg" /> </div> <script type="text/javascript"> $(function(){ var test = $("#test"); var html = ''; for(var i=0;i<5;i++){ html+='<div style="width:60px;height:300px;position:absolute;top:0px;left:'+60*i+'px;background:url(http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_test1.jpg) '+-60*i+'px 0px no-repeat;"></div>'; } test.prepend(html); test.find("div").eq(0).animate({ "top":"320px"},2000); test.find("div").eq(1).animate({ "top":"320px"},2500); test.find("div").eq(2).animate({ "top":"320px"},3000); test.find("div").eq(3).animate({ "top":"320px"},3500); test.find("div").eq(4).animate({ "top":"320px"},4000); test.find("div").eq(0).delay(5000); test.find("div").eq(4).delay(3000); test.find("div").eq(1).delay(5000); test.find("div").eq(3).delay(4000); test.find("div").eq(2).delay(5000); test.find("div").eq(0).animate({ "left":"-320px","top":"0px","width":"300px","height":"300px"},5000); test.find("div").eq(4).animate({ "left":"320px","top":"0px","width":"300px","height":"300px","background-position":"0px 0px"},5000); test.find("div").eq(1).animate({ "left":"-320px","top":"320px","width":"300px","height":"300px","background-position":"0px 0px"},4500); test.find("div").eq(3).animate({ "left":"320px","top":"320px","width":"300px","height":"300px","background-position":"0px 0px"},4500); test.find("div").eq(2).animate({ "left":"0px","top":"320px","width":"300px","height":"300px","background-position":"0px 0px"},4000); test.find("div").eq(0).delay(2000); test.find("div").eq(4).delay(2000); test.find("div").eq(1).delay(2000); test.find("div").eq(3).delay(2000); test.find("div").eq(2).delay(2000); test.find("div").eq(0).animate({ "left":"0px","top":"0px","width":"300px","height":"300px","background-position":"0px 0px"},5000); test.find("div").eq(4).animate({ "left":"0px","top":"0px","width":"300px","height":"300px","background-position":"0px 0px"},5000); test.find("div").eq(1).animate({ "left":"0px","top":"0px","width":"300px","height":"300px","background-position":"0px 0px"},4500); test.find("div").eq(3).animate({ "left":"0px","top":"0px","width":"300px","height":"300px","background-position":"0px 0px"},4500); test.find("div").eq(2).animate({ "left":"0px","top":"0px","width":"300px","height":"300px","background-position":"0px 0px"},4000); test.find("div").eq(0).delay(2000); test.find("div").eq(4).delay(2000); test.find("div").eq(1).delay(2000); test.find("div").eq(3).delay(2000); test.find("div").eq(2).delay(2000); test.find("div").eq(0).animate({ "left":"0px","top":"300px","width":"60px","height":"300px","background-position":"0px 0px"},5000,function(){test.find("img").css({"position":"absolute","left":"0px","top":"0px","z-index":"999"}); test.find("div").css({"background":"url(http://images.cnblogs.com/cnblogs_com/kuikui/354173/r_test3.jpg) no-repeat"});}); test.find("div").eq(4).animate({ "left":"240px","top":"300px","width":"60px","height":"300px","background-position":"-240px 0px"},5000); test.find("div").eq(1).animate({ "left":"60px","top":"200px","width":"60px","height":"300px","background-position":"-60px 0px"},4500); test.find("div").eq(3).animate({ "left":"180px","top":"200px","width":"60px","height":"300px","background-position":"-180px 0px"},4500); test.find("div").eq(2).animate({ "left":"120px","top":"300px","width":"60px","height":"300px","background-position":"-120px 0px"},4000); }); </script> </body> </html>

目录
相关文章
N..
|
5月前
|
JavaScript 前端开发 UED
jQuery动画特效
jQuery动画特效
N..
63 1
|
5月前
|
JavaScript
jquery动画与事件案例
jquery动画与事件案例
|
5月前
|
机器学习/深度学习 JavaScript
|
6天前
|
JavaScript 前端开发 UED
jQuery 动画
【10月更文挑战第8天】
105 55
|
4月前
|
移动开发 JavaScript 前端开发
老程序员分享:jQuery笔记(四)jQuery中的动画
老程序员分享:jQuery笔记(四)jQuery中的动画
45 0
|
1月前
|
JavaScript
jQuery 停止动画
jQuery 停止动画
15 4
|
1月前
|
缓存 JavaScript 前端开发
jQuery 效果- 动画
jQuery 效果- 动画
20 4
|
1月前
|
JavaScript 前端开发
jQuery 效果- 动画
jQuery 效果- 动画
39 11
|
1月前
|
JavaScript
jQuery 停止动画
jQuery 停止动画
24 11
|
2月前
|
JavaScript 前端开发
如何在Vue2.X/Vue3.X项目引入jQuery,以及增加jQuery.easing扩展?让你的动画效果更加丝滑!
如何在Vue 2或Vue 3项目中引入jQuery及其动画扩展库jQuery.easing,以实现更丰富的动画效果。
137 0
如何在Vue2.X/Vue3.X项目引入jQuery,以及增加jQuery.easing扩展?让你的动画效果更加丝滑!