本文实例讲述了JS模拟酷狗音乐播放器收缩折叠关闭效果代码。分享给大家供大家参考,具体如下:
这是一款模拟酷狗音乐播放器的关闭特效,采用JavaScript实现,关闭的时候播放界面缩成一条线,然后消失,就像有些电视机突然停电的效果,很有意思的网页动画特效。
运行效果截图如下:
在线演示地址如下:
http://demo.jb51.net/js/2015/js-kugou-music-player-style-demo/
具体代码如下:
<!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>酷狗音乐播放器的关闭特效,采用JavaScript实现</title> <style type="text/css"> * { padding:0px; margin:0px; } #outer { width:952px; height: 640px; position:absolute; left:100px; top:20px; } #div1 { width:952px; height: 640px; overflow:hidden; position:absolute;font-size:0px; } #div1 a { position:absolute; width:23px; height:21px; right:5px; top:5px; display:block; z-index:100; background:url(images/kugou.jpg) no-repeat 957px 645px;} #div1 a:hover { background:url(images/hover.jpg) no-repeat right top; } #line { height:3px; width:952px; display:none; z-index:100; position:absolute; left:0px; top:0px; font-size:0px; } #light{ /*width:50px; height:10px;*/ position:absolute; left:50%; top:50%;/* margin-left:-25px; margin-top:-5px;*/ width:0px; height:0px; filter:alpha(opacity:0);opacity:0;); overflow:hidden;} </style> <script type="text/javascript"> function css(obj, attr, value) { if(arguments.length==2) { if(attr!='opacity') { return parseInt(obj.currentStyle"alpha(opacity:"+value+")"; obj.style.opacity=value/100; break; default: obj.style[attr]=value; } return function (attr_in, value_in){css(obj, attr_in, value_in)}; } var MIAOV_MOVE_TYPE={ BUFFER: 1, FLEX: 2 };//json function miaovStopMove(obj) { clearInterval(obj.timer); } function miaovStartMove(obj, oTarget,iSpeedCtrol, iType, fnCallBack, fnDuring) { var fnMove=null; if(obj.timer) { clearInterval(obj.timer); } switch(iType) { case MIAOV_MOVE_TYPE.BUFFER: fnMove=miaovDoMoveBuffer; break; case MIAOV_MOVE_TYPE.FLEX: fnMove=miaovDoMoveFlex; break; } obj.timer=setInterval(function (){ fnMove(obj, oTarget,iSpeedCtrol, fnCallBack, fnDuring); }, 30); } function miaovDoMoveBuffer(obj, oTarget,iSpeedCtrol, fnCallBack, fnDuring) { var bStop=true; var attr=''; var speed=0; var cur=0; for(attr in oTarget) { cur=css(obj, attr); if(oTarget[attr]!=cur) { bStop=false; speed=(oTarget[attr]-cur)/iSpeedCtrol; speed=speed>0"text/javascript"> window.onload=function(){ var oDiv1 = document.getElementById('div1'); var oAbtn = oDiv1.getElementsByTagName('a')[0]; var oImg1 = document.getElementById('img1'); var oImg2 = document.getElementById('img2'); var oImg3 = document.getElementById('img3'); var oLine = document.getElementById('line'); var oLight = document.getElementById('light'); oAbtn.onclick=function(){ miaovStartMove(oDiv1, {height:3,marginTop:315},1.5, MIAOV_MOVE_TYPE.BUFFER,function(){ oImg1.style.display='none'; oLine.style.display='block'; miaovStartMove(oDiv1, {width:0,marginLeft:476},2, MIAOV_MOVE_TYPE.BUFFER); miaovStartMove(oLine, {width:0},2, MIAOV_MOVE_TYPE.BUFFER); miaovStartMove(oImg2, {width:0},2, MIAOV_MOVE_TYPE.BUFFER,function(){ miaovStartMove(oImg3, {width:200,height:10},1, MIAOV_MOVE_TYPE.BUFFER); miaovStartMove(oLight, {width:200,height:10,marginLeft:-100,marginTop:-5,opacity:100},1, MIAOV_MOVE_TYPE.BUFFER,function(){ miaovStartMove(oLight, {opacity:0},1, MIAOV_MOVE_TYPE.BUFFER); }); }); }); } } </script> </head> <body> <div id="outer"> <div id="light"><img id="img3" src="/UploadFiles/2021-04-02/line1.png">希望本文所述对大家JavaScript程序设计有所帮助。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“JS模拟酷狗音乐播放器收缩折叠关闭效果代码”评论...