jQuery动画
来源:互联网 发布:c语言画玫瑰花程序 编辑:程序博客网 时间:2024/06/01 09:39
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>jQuery动画</title><style type="text/css"> #msg{ border:2px solid #CCC; width:80px; height:20px; line-height:20px; text-align:center; position:fixed; bottom:10px; right:10px; background-color:pink; display:none; } /*设置相对/绝对/固定定位才能做出动画效果,动画就是连续改变元素的偏移量*/ img{ position:relative; } #gg{ border:2px solid red; width:200px; height:100px; position:fixed; right:-180px; top:50px; }</style><script type="text/javascript" src="../js/jquery-1.11.1.js"></script><script type="text/javascript"> function f1(){ $("img:eq(0)").show("fast",function (){console.log("开始")}); } function f2(){//fadeOut(执行时间,回调函数) 回调函数:完成时自动调用的函数$("img:eq(0)").hide(3000,function (){console.log("完成")}); //显示与隐藏动画的实现原理://通过定时器(线程)连续改变元素的样式(大小和透明度)//f2相当于主线程,动画相当于支线程//图片动画还未执行完毕此时会直接输出over,使用回调函数可以解决此问题console.log("over"); } function f3(){$("#msg").fadeIn(1000).fadeOut(2500); }//animate一般使用前两个参数就足够了 function f4(){$("img:eq(0)").animate({"left":"300px"},2000).animate({"top":"300px"},2000).animate({"left":"0"},2000).animate({"top":"0"},2000); } //广告案例,鼠标移入弹出全部,鼠标移出缩回(可用合成事件) $(function(){$("#gg").hover( function(){$(this).animate({"right":"0"},500); }, function(){$(this).animate({"right":"-180px"},1000); }); });</script></head><body> <input type="button" value="显示" onclick="f1();"/> <input type="button" value="隐藏" onclick="f2();"/> <input type="button" value="删除" onclick="f3();"/> <input type="button" value="动画" onclick="f4();"/> <p> <img src="../images/01.jpg" /> </p> <div id="msg" >删除成功!</div> <div id="gg">广告</div> <h2>最后</h2></body></html>
0 0
- jQuery动画
- jquery动画
- jQuery动画
- jQuery动画
- jQuery动画
- jquery 动画
- JQuery动画
- jquery 动画
- jQuery动画
- jquery动画
- jquery动画
- jQuery-动画
- jquery动画
- jquery动画
- jQuery动画
- jQuery动画
- jQuery动画
- jquery 动画
- 将后台List对象以Json格式返回到前台Ajax请求
- 乌班图下基于openssl的密码学实验
- sdust 2681 求个最大值 (数学+思维)
- C语言学习历程——编程练习2——02
- 精讲WEB前端之Flex弹性盒模型属性,对比每一属性值和效果
- jQuery动画
- 1、MAC常用工具汇总一
- js实现的下拉框二级联动效果
- 定义一个不能被继承的类
- poj1014(较复杂的背包问题)
- 抽象类 接口 的个人理解
- C语言学习历程——编程练习2——03
- Java JDBC连接SQL Server2005错误:通过端口 1433 连接到主机 localhost 的 TCP/IP 连接失败
- Ajax、JSON