jquery animate 动画效果使用解析
2013-07-03 21:51
771 查看
animate的意思是:使有生气;驱动;使栩栩如生地动作;赋予…以生命
作为形容词:有生命的;活的;有生气的;生气勃勃的
先看动画效果:
http://keleyi.com/keleyi/phtml/jquery/index.htm
animate()在jquery中作为一个方法,可用于创建动画效果
以下是实例代码:
博客园计划
定义和用法
animate() 方法执行 CSS 属性集的自定义动画。
该方法通过CSS样式将元素从一个状态改变为另一个状态。CSS属性值是逐渐改变的,这样就可以创建动画效果。
只有数字值可创建动画(比如 "margin:30px")。字符串值无法创建动画(比如 "background-color:red")。
注释:使用 "+=" 或 "-=" 来创建相对动画(relative animations)。
语法 1
$(selector).animate(styles,speed,easing,callback)
参数
styles
必需。规定产生动画效果的 CSS 样式和值。
可能的 CSS 样式值(提供实例):
backgroundPosition
borderWidth
borderBottomWidth
borderLeftWidth
borderRightWidth
borderTopWidth
borderSpacing
margin
marginBottom
marginLeft
marginRight
marginTop
outlineWidth
padding
paddingBottom
paddingLeft
paddingRight
paddingTop
height
width
maxHeight
maxWidth
minHeight
minWidth
font
fontSize
bottom
left
right
top
letterSpacing
wordSpacing
lineHeight
textIndent
注释:CSS 样式使用 DOM 名称(比如 "fontSize")来设置,而非 CSS 名称(比如 "font-size")。
speed
可选。规定动画的速度。默认是 "normal"。
可能的值:
毫秒 (比如 1500)
"slow"
"normal"
"fast"
easing
可选。规定在不同的动画点中设置动画速度的 easing 函数。
内置的 easing 函数:
swing
linear
扩展插件中提供更多 easing 函数。
allback
可选。animate 函数执行完之后,要执行的函数。
语法 2
$(selector).animate(styles,options)
styles 必需。规定产生动画效果的 CSS 样式和值(同上)。
options
可选。规定动画的额外选项。
可能的值:
speed - 设置动画的速度
easing - 规定要使用的 easing 函数
callback - 规定动画完成之后要执行的函数
step - 规定动画的每一步完成之后要执行的函数
queue - 布尔值。指示是否在效果队列中放置动画。如果为 false,则动画将立即开始
specialEasing - 来自 styles 参数的一个或多个 CSS 属性的映射,以及它们的对应 easing 函数
本文转自柯乐义:http://keleyi.com/a/bjac/5b62295315de9ace.htm
作为形容词:有生命的;活的;有生气的;生气勃勃的
先看动画效果:
http://keleyi.com/keleyi/phtml/jquery/index.htm
animate()在jquery中作为一个方法,可用于创建动画效果
以下是实例代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>jquery animate动画--柯乐义</title><base target="_blank" /> <script type="text/javascript" src="http://keleyi.com/keleyi/pmedia/jquery-1.9.1.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $("button#bGo_kel"+"eyi_com").click(function () { $("div#divAnimate_keleyi_com").animate({ top: "-280px", opacity: "0.5" }, "slow"); $("div#divAnimate_keleyi_com").animate({ fontSize: "5em" }, "slow"); }); $("button#bBack_keleyi_com").click(function () { $("div#divAnimate_ke"+"leyi_com").animate({ top: "0px", opacity: "1" }, "slow"); $("div#divAnimate_keleyi_com").animate({ fontSize: "1em" }, "slow"); }); }); </script> </head> <body> <div style="width:400px;margin:10px auto;border:1px solid green"> <h2>animate动画效果演示</h2> <button id="bGo_keleyi_com">开始动画</button> <button id="bBack_keleyi_com">回滚动画</button> <a href="http://keleyi.com/a/bjac/5b62295315de9ace.htm" target="_blank">原文</a><br /><br /> <div id="divAnimate_keleyi_com" style="background:green;height:110px;width:400px;position:relative;color:White">keleyi.com</div> </div> <div><a href="http://keleyi.com/keleyi/phtml/jquery/1.htm">jquery修改链接</a> <a href="http://keleyi.com/keleyi/phtml/jquery/2.htm">jquery弹出窗体</a></div> </body> </html>
博客园计划
定义和用法
animate() 方法执行 CSS 属性集的自定义动画。
该方法通过CSS样式将元素从一个状态改变为另一个状态。CSS属性值是逐渐改变的,这样就可以创建动画效果。
只有数字值可创建动画(比如 "margin:30px")。字符串值无法创建动画(比如 "background-color:red")。
注释:使用 "+=" 或 "-=" 来创建相对动画(relative animations)。
语法 1
$(selector).animate(styles,speed,easing,callback)
参数
styles
必需。规定产生动画效果的 CSS 样式和值。
可能的 CSS 样式值(提供实例):
backgroundPosition
borderWidth
borderBottomWidth
borderLeftWidth
borderRightWidth
borderTopWidth
borderSpacing
margin
marginBottom
marginLeft
marginRight
marginTop
outlineWidth
padding
paddingBottom
paddingLeft
paddingRight
paddingTop
height
width
maxHeight
maxWidth
minHeight
minWidth
font
fontSize
bottom
left
right
top
letterSpacing
wordSpacing
lineHeight
textIndent
注释:CSS 样式使用 DOM 名称(比如 "fontSize")来设置,而非 CSS 名称(比如 "font-size")。
speed
可选。规定动画的速度。默认是 "normal"。
可能的值:
毫秒 (比如 1500)
"slow"
"normal"
"fast"
easing
可选。规定在不同的动画点中设置动画速度的 easing 函数。
内置的 easing 函数:
swing
linear
扩展插件中提供更多 easing 函数。
allback
可选。animate 函数执行完之后,要执行的函数。
语法 2
$(selector).animate(styles,options)
styles 必需。规定产生动画效果的 CSS 样式和值(同上)。
options
可选。规定动画的额外选项。
可能的值:
speed - 设置动画的速度
easing - 规定要使用的 easing 函数
callback - 规定动画完成之后要执行的函数
step - 规定动画的每一步完成之后要执行的函数
queue - 布尔值。指示是否在效果队列中放置动画。如果为 false,则动画将立即开始
specialEasing - 来自 styles 参数的一个或多个 CSS 属性的映射,以及它们的对应 easing 函数
本文转自柯乐义:http://keleyi.com/a/bjac/5b62295315de9ace.htm
相关文章推荐
- jQuery动画效果animate和scrollTop结合使用实例
- jquery中的动画效果方法animate()及其回调函数的使用
- jquery animate 动画效果使用说明
- Jquery使用animate实现css3的transform动画效果
- 关于火狐中使用jquery的animate做动画效果的问题解决
- jQuery动画效果animate和scrollTop结合使用实例
- jQuery动画效果animate和scrollTop结合使用实例
- jQuery动画效果animate和scrollTop结合使用实例
- jQuery动画效果animate和scrollTop结合使用实例
- jQuery动画效果animate和scrollTop结合使用实例
- jQuery动画效果animate和scrollTop结合使用实例
- coco2d-x 使用Action中的Animate实现动画效果
- 使用jQuery制作滑动动画效果的层
- jquery的动画效果animate附加一个滚动回到页面的例子
- jQuery动画animate方法使用介绍
- JQuery动画animate的stop方法使用详解
- 使用 jquery.easing.js 增强动画过渡效果
- 使用jQuery.animate实现简单的页面切换效果
- jQuery动画animate和scrollTop结合使用
- jQuery使用animate创建动画用法实例