通过jquery实现页面的动画效果
来源:互联网 发布:节拍器软件 编辑:程序博客网 时间:2024/06/05 15:10
本文部分内容引用自http://www.runoob.com/jquery/jquery-animate.html
有很多函数可以用来实现动画效果,其中animate函数为最为常见的函数之一。以下为对该函数使用方式的简要介绍。
animate函数基本形式
通过animate实现动画效果的基本形式为:
$(selector).animate({params},speed,callback);其中{params}为必须项,它是一个对象,指明了我们希望指定元素通过动画效果运行后,其所具有的的CSS样式,speed和callback则皆为可选项,其中speed指明了动画运行的速度,其值可为数值类型(如1000表示动画在1s内变为params指定样式)、slow以及fast。callback指明动画运行结束后要执行的函数。
代码示例:
<!DOCTYPE html><html><head><script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script><script> $(document).ready(function(){ $("button").click(function(){ $("div").animate({ left:'250px', opacity:'0.5', height:'150px', width:'150px' }); });});</script> </head> <body><button>Start Animation</button><p>By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!</p><div style="background:#98bf21;height:100px;width:100px;position:absolute;"></div></body></html>
{params}对象中的变量的多种赋值形式
关于{params}对象中的变量,可以通过如下形式赋值。
绝对值形式
在上文给出的代码示例便是通过绝对值形式来赋值params对象的
相对值形式
比如说在变量值前面加上“+”“-”等。代码示例:
<script> $(document).ready(function(){ $("button").click(function(){ $("div").animate({ left:'250px', height:'+=150px', width:'+=150px' }); });});</script>
show、hide以及toogle
params对象的变量值,我们同样可以赋值为以上三个值,比如下面的代码,其作用便是使div标签内容消失。
$("button").click(function(){ $("div").animate({ height:'toggle' });});
0 0
- 通过jquery实现页面的动画效果
- 通过js实现简单的动画效果
- jQuery动画效果实现
- jquery实现动画效果
- jQuery实现动画效果
- jQuery实现动画效果
- jquery实现动画效果
- JQuery实现动画效果
- jQuery动画效果实现
- jQuery实现动画效果的例子
- 通过jQuery来实现页脚永远固定在页面底部的效果
- jQuery实现的加载页面过渡效果
- jQuery封装的页面数据加载动画效果
- 利用css3+jquery写具有动画效果的登录页面
- 通过画图实现动画效果
- JQuery的动画效果
- jquery的动画效果
- jquery animate实现动画效果
- Android SDK开发 -- TitleBar重构 (代理模式的使用)
- /etc/ld.so.conf文件
- Hdu 2037 之解题报告
- Ubuntu下为Firefox安装Adobe Flash Player
- Exception 'yii\db\Exception' with message 'SQLSTATE[HY000] [2002] No such file or directory’错误的解决方法
- 通过jquery实现页面的动画效果
- sublime text安装ctags定位函数
- Android 编程技巧之 ----- 随意从当前 Activity 退出应用
- 压测总结
- mac使用技巧
- Tracking-Learning-Detection原理分析
- Android四大组件之Content Provider
- TLD算法学习之L-K光流法理论篇二
- Explosive