让用户鼠标点击按钮后图层旋转显示特效,可以自由向左向右选择旋转,立体感很强,可用作商品旋转展示特效。
<!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=gb2312"> <meta name="keywords" content="武鸣人网站,武鸣信息网,武鸣本地网,武鸣信息资源平台,减肥,健身,励志,励志语录,js特效,网页特效,www.wuming.ren"> <meta name="description" content="欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。"> <title>按钮控制图层旋转js特效_武鸣人</title> <style type="text/css"> #www_wuming_ren{position:relative;margin:20px auto;width:800px;border:1px solid #999999;} .wuming_ren{position:absolute;height:40px;width:60px;background:#999999;border:1px solid #eeeeee;cursor:pointer;} </style> <script language="javascript"> var len; var showerObj; var listObj; var showerWidth=800; var showerHeight=400; var r; var cR=0; var ccR=0; var timer=0; window.onload=function(){ showerObj=document.getElementById("www_wuming_ren"); listObj=showerObj.getElementsByTagName("div"); len=listObj.length; r=Math.PI/180*360/len; for(var i=0;i<len;i++){ var wuming_ren=listObj[i]; wuming_ren.style.top=showerHeight/2+Math.sin(r*i)*showerWidth/2-20+"px"; wuming_ren.style.left=showerWidth/2+Math.cos(r*i)*showerWidth/2-30+"px"; wuming_ren.rotate=(r*i+2*Math.PI)%(2*Math.PI); wuming_ren.onclick=function(){ cR=Math.PI/2-this.rotate; timer || (timer=setInterval(rotate,10)); } } var rX=showerObj.offsetLeft+showerWidth/2; var ry=showerObj.offsetTop+showerHeight/2; var rotate=function(){ ccR=(ccR+2*Math.PI)%(2*Math.PI); if(cR-ccR<0) cR=cR+2*Math.PI; if(cR-ccR<Math.PI){ ccR=ccR+(cR-ccR)/19; }else{ ccR=ccR-(2*Math.PI+ccR-cR)/19; } if(Math.abs((cR+2*Math.PI)%(2*Math.PI)-(ccR+2*Math.PI)%(2*Math.PI))<Math.PI/720){ ccR=cR; clearInterval(timer); timer=0; } for(var i=0;i<len;i++){ var wuming_ren=listObj[i]; var w,h; var sinR=Math.sin(r*i+ccR); var cosR=Math.cos(r*i+ccR); w=60+0.6*60*sinR; h=(40+0.6*40*sinR); wuming_ren.style.cssText +=";width:"+w+"px;height:"+h+"px;top:"+parseInt(showerHeight/2+sinR*showerWidth/2/3-w/2)+"px;left:"+parseInt(showerWidth/2+cosR*showerWidth/2-h/2)+"px;z-index:"+parseInt(showerHeight/2+sinR*showerWidth/2/3-w/2)+";"; } } document.getElementById("l").onclick=function(){ cR=(cR+r+2*Math.PI)%(2*Math.PI); timer || (timer=setInterval(rotate,10)); } document.getElementById("r").onclick=function(){ cR=(cR-r+2*Math.PI)%(2*Math.PI); timer || (timer=setInterval(rotate,10)); } rotate(); }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) </script> </head> <body> <a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr> <!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。--> <script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script> <script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script> <input id="l" type="button" value="left"> <input id="r" type="button" value="right"> <div id="www_wuming_ren"> <div class="wuming_ren">武鸣人一号</div> <div class="wuming_ren">武鸣人二号</div> <div class="wuming_ren">武鸣人三号</div> <div class="wuming_ren">武鸣人四号</div> <div class="wuming_ren">武鸣人五号</div> <div class="wuming_ren">武鸣人六号</div> <div class="wuming_ren">武鸣人七号</div> <div class="wuming_ren">武鸣人八号</div> <div class="wuming_ren">武鸣人九号</div> <div class="wuming_ren">武鸣人十号</div> <div class="wuming_ren">武鸣人十一号</div> <div class="wuming_ren">武鸣人十二号</div> <div class="wuming_ren">武鸣人十三号</div> <div class="wuming_ren">武鸣人十四号</div> <div class="wuming_ren">武鸣人十五号</div> </div> </body> </html>
本文来自武鸣人网站,转载请注明出处