jQuery animate() 方法
来源:互联网 发布:百度贴吧数据统计 编辑:程序博客网 时间:2024/05/17 22:14
实例
通过改变元素的高度,对元素应用动画:
$("button").click(function(){$("#box").animate({height:"300px"});});
定义和用法
animate() 方法执行 CSS 属性集的自定义动画。
该方法通过 CSS 样式将元素从一个状态改变为另一个状态。CSS属性值是逐渐改变的,这样就可以创建动画效果。
只有数字值可创建动画(比如 “margin:30px”)。字符串值无法创建动画(比如 “background-color:red”)。
提示:请使用 “+=” 或 “-=” 来创建相对动画。
语法
(selector).animate({styles},speed,easing,callback)
paddingLeft
代替 padding-left
,marginRight
代替 margin-right
,依此类推。 可以应用动画的属性: backgroundPositionX backgroundPositionY borderWidth borderBottomWidth borderLeftWidth borderRightWidth borderTopWidth borderSpacing margin marginBottom marginLeft marginRight marginTop outlineWidth padding paddingBottom paddingLeft paddingRight paddingTop height width maxHeight maxWidth minHeight minWidth fontSize bottom left right top letterSpacing wordSpacing lineHeight textIndent 提示:颜色动画不包含在核心 jQuery 库中。如果您想要应用动画颜色,您需要从 jQuery.com 下载 颜色动画插件。 speed 可选。规定动画的速度。 可能的值: 毫秒 “slow” “fast” easing 可选。规定在动画的不同点中元素的速度。默认值是 “swing”。 可能的值: “swing” - 在开头/结尾移动慢,在中间移动快 “linear” - 匀速移动 提示:扩展插件中提供更多可用的 easing 函数。 callback 可选。animate 函数执行完之后,要执行的函数。 如需学习更多有关 callback 的内容,请访问我们的 jQuery Callback 这一章。Alternate 语法
(selector).animate({styles},{options})
实例
<!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title></title> <script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script> <script>$(document).ready(function(){ $("button").click(function(){ var div = $("div"); startAnimation(); function startAnimation(){ div.animate({height:300},"slow"); div.animate({width:300},"slow"); div.css("background-color","blue"); div.animate({height:100},"slow"); div.animate({width:100},"slow",startAnimation); } });});</script> </head> <body> <button>开始动画</button> <div style="width:50px;height:50px;position:absolute;left:10px;top:50px;background-color:red;"></div> </body></html>
阅读全文
0 0
- jQuery--animate() 方法
- jQuery animate方法
- 【jQuery】 效果 - animate() 方法
- jQuery animate方法
- jQuery 效果 - animate() 方法
- jQuery 动画 - animate() 方法
- jQuery 效果 - animate() 方法
- jQuery 效果 - animate() 方法
- jQuery 效果 - animate() 方法
- jQuery 效果 - animate() 方法
- jQuery 效果 - animate() 方法
- jQuery--animate()方法
- 关于JQuery animate()方法
- 关于JQuery animate()方法
- jQuery animate() 方法
- JQuery自定义动画animate方法
- JQuery自定义动画animate方法
- jQuery 动画 - animate() 方法简介
- JavaScript(十一)AjAx
- 100脚的STM32F103VE单片机通过FSMC接口读写DS12C887时钟芯片中的寄存器
- 面试题:判断偶数和素数
- AngularJS中使用$.ajax绑定失败的处理方法
- linux每天打印一个tomcat日志(tomcat6)
- jQuery animate() 方法
- Jmeter如何配置JDBC(postgres)并执行SQL
- mysql笔记——事务
- java多态,如何理解父类引用指向子类对象
- redis集群之新增节点
- jQuery.bind用法
- Sublime text c++环境配置
- elasticsearch -2.3.x head插件安装(windows系统)
- 【版本更新】完整UI库Kendo UI发布R3 2017|附下载