马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
1.自定义动画
1.animate(properties,duration,easing,callback)
* properties - 设置相关动画需要的CSS的属性内容
* duration - 设置自定义动画执行的时长(毫秒)
* easing - 要使用的擦除效果的名称(需要插件支持).默认jQuery提供"linear" 和 "swing".
* callback - 自定义动画执行完毕后的回调函数
例如:
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>jQuery自定义动画一</title>
- <script src="jquery-1.11.3.js"></script>
- <style>
- div {
- width : 200px;
- height : 200px;
- border : solid 1px black;
- background : pink;
- position : absolute;
- top : 100px;
- left : 100px;
- }
- </style>
- </head>
- <body>
- <div></div>
- <script>
- $("div").animate({
- width : 100,
- height : 100,
- top : 300,
- left : 300
- },3000,function(){
- alert("hello world!!");
- });
- </script>
- </body>
- </html>
复制代码效果如下:
2.animate(properties,options)
* properties - 设置相关动画需要的CSS的属性内容
* options - 选项
* duration - 设置自定义动画执行的时长(毫秒)
* easing - 要使用的擦除效果的名称(需要插件支持).默认jQuery提供"linear" 和 "swing".
* complete - 自定义动画执行完毕后的回调函数
* queue - Boolean值,(默认值: true) 设定为false将使此动画不进入动画队列
例如:
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>jQuery自定义动画一</title>
- <script src="jquery-1.11.3.js"></script>
- <style>
- div {
- width : 200px;
- height : 200px;
- border : solid 1px black;
- background : pink;
- position : absolute;
- top : 100px;
- left : 100px;
- }
- </style>
- </head>
- <body>
- <div></div>
- <script>
- $("div").animate({
- width : 100,
- height : 100,
- top : 300,
- left : 300
- },{
- duration : 3000,
- complete : function(){
- alert("hello world!!");
- }
- })
- </script>
- </body>
- </html>
复制代码效果与上一样。
* 注意 - 有些CSS的属性不能使用
* backgroundColor
* borderBottomColor
* borderLeftColor
* borderRightColor
* borderTopColor
* Color
* outlineColor
* 排队与并发效果
* 并发效果 - 指多个动画同时执行
例如:
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>jQuery自定义动画 -- 并发</title>
- <script src="jquery-1.11.3.js"></script>
- <style>
- div {
- width : 200px;
- height : 200px;
- border : solid 1px black;
- background : pink;
- position : absolute;
- top : 100px;
- left : 100px;
- }
- </style>
- </head>
- <body>
- <div></div>
- <script>
- $("div").animate({
- width : 100,
- height : 100
- },{
- duration : 3000
- }).animate({
- left : 500
- },{
- duration : 3000,
- queue : false
- }).animate({
- top :500
- },{
- duration : 3000,
- queue : false
- }).hide(3000);
- </script>
- </body>
- </html>
复制代码 * 排队效果 - 指多个动画按照先后顺序执行
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>jQuery自定义动画 -- 排队效果</title>
- <script src="jquery-1.11.3.js"></script>
- <style>
- div {
- width : 300px;
- height : 300px;
- border : solid 1px black;
- background : pink;
- position : absolute;
- top : 100px;
- left : 100px;
- }
- </style>
- </head>
- <body>
- <div></div>
- <script>
- $("div").animate({
- width : 100,
- height : 100
- }).animate({
- left : 500
- },{
- duration : 3000
- }).animate({
- top : 500
- },{
- duration : 3000
- })
- </script>
- </body>
- </html>
复制代码 |