[JQ权威指南]animate() 方法

编程之家收集整理的这篇文章主要介绍了[JQ权威指南]animate() 方法编程之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

定义和用法
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 函数
callback
可选。animate 函数执行完之后,要执行的函数
如需学习更多有关 callback 的内容,请访问我们的 jQuery Callback 这一章。
语法 2
$(selector).animate(styles,options)
参数 描述
styles 必需。规定产生动画效果的 CSS 样式和值(同上)。
options
可选。规定动画的额外选项。
可能的值:
speed - 设置动画的速度
easing - 规定要使用的 easing 函数
callback - 规定动画完成之后要执行的函数
step - 规定动画的每一步完成之后要执行的函数
queue - 布尔值。指示是否在效果队列中放置动画。如果为 false,则动画将立即开始
specialEasing - 来自 styles 参数的一个或多个 CSS 属性的映射,以及它们的对应 easing 函数

<!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>
<Meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>队列中的动画</title>
<script type="text/javascript" src="../jquery-2.1.4.js">
</script>
<style type="text/css">
    div{ border: solid 1px #666; background-color:#eee;
        width:50px; height:50px; font-size:13px; padding:5px}
</style>
<script type="text/javascript" >
    $(function(){
        $("div").click(function(){
            $(this)
            .animate({height:100},"slow")
            .animate({width:100},"slow")
            .animate({height:50},"slow")
            .animate({width:50},"slow")

            })
        })
</script>
</head>
<body>
    <div>队列</div>
</body>
</html>

原文地址:https://david.blog.csdn.net

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


jQuery表单验证提交:前台验证一(图文+视频)
jQuery表单验证提交:前台验证二(图文+视频)
jQuery如何实时监听获取input输入框的值
jQuery如何实现定时重定向
jquery如何获取复选框选中的值
jQuery如何清空form表单数据
JQuery怎么循环输出数组元素
jquery怎么实现点击刷新当前页面