很漂亮的一个拖拽页面实现翻页功能特效,压住鼠标往左右拖动都可以,实用鼠标拖拽翻页js特效代码。
<!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>拖动页面实现翻页效果_武鸣人</title> <style type="text/css"> html,body{ width:100%; height:100%; border:0px; margin:0px; overflow:hidden; } #www_wuming_ren{ width:800px; height:500px; overflow:hidden; background:lightblue; } .page{ position:absolute; width:300px; height:400px; left:350px; top:50px; background:#FFF; border:1px solid #999; } ul{ list-style:none; height:320px; margin:20px; padding:0px; background:#EEE; } li{ font-size:12px; height:20px; line-height:20px; border-bottom:1px dashed #999; } li span{ float:right; } li a{ color:#000; text-decoration:none; } li a:hover{ text-decoration:underline; } .tip{ display:block; height:20px; margin:0px 20px; line-height:20px; text-align:center; font-size:12px; background:#999; } </style> <script type="text/javascript"> function id(obj){ return document.getElementById(obj); }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) var page; var mx; var md=false; var sh=0; var en=false; window.onload=function(){ page=id("www_wuming_ren").getElementsByTagName("div"); if(page.length>0){ page[0].style.zIndex=2; } for(i=0;i<page.length;i++){ page[i].innerHTML+="<span class=\"tip\">"+(i+1)+"/"+page.length+"页 拖拽翻页</span>"; page[i].id="page"+i; page[i].i=i; page[i].onmousedown=function(e){ if(!en){ if(!e){e=e||window.event;} ex=e.pageX?e.pageX:e.x; mx=350-ex; this.style.cursor="move"; md=true; if(document.all){ this.setCapture(); }else{ window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP); } } } page[i].onmousemove=function(e){ if(md){ en=true; if(!e){e=e||window.event;} ex=e.pageX?e.pageX:e.x; this.style.left=ex+mx+"px"; if(this.offsetLeft<350){ var cu=(this.i==0)?page.length-1:this.i-1; page[sh].style.zIndex=0; page[cu].style.zIndex=1; this.style.zIndex=2; sh=cu; } if(this.offsetLeft>350){ var cu=(this.i==page.length-1)?0:this.i+1; page[sh].style.zIndex=0; page[cu].style.zIndex=1; this.style.zIndex=2; sh=cu; } } } page[i].onmouseup=function(){ this.style.cursor="default"; md=false; if(this.offsetLeft==350){ en=false; } if(document.all){ this.releaseCapture(); }else{ window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP); } flyout(this); } } }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) function flyout(obj){ if(obj.offsetLeft < 350){ if( (obj.offsetLeft - 10) > 50 ){ obj.style.left=obj.offsetLeft - 10 + "px"; window.setTimeout("flyout(id('"+obj.id+"'));",0); }else{ obj.style.left= 50 +"px"; obj.style.zIndex=0; flyin(id(obj.id)); } } if(obj.offsetLeft > 350){ if((obj.offsetLeft + 10) < 650){ obj.style.left=obj.offsetLeft + 10 + "px"; window.setTimeout("flyout(id('"+obj.id+"'));",0); }else{ obj.style.left= 650 + "px"; obj.style.zIndex=0; flyin(id(obj.id)); } } }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) function flyin(obj){ if(obj.offsetLeft<350){ if((obj.offsetLeft + 10) < 350){ obj.style.left=obj.offsetLeft + 10+"px"; window.setTimeout("flyin(id('"+obj.id+"'));",0); }else{ obj.style.left= 350 +"px"; en=false; } } if(obj.offsetLeft>350){ if((obj.offsetLeft - 10) > 350){ obj.style.left=obj.offsetLeft - 10 +"px"; window.setTimeout("flyin(id('"+obj.id+"'));",0); }else{ obj.style.left=350+"px"; en=false; } } }//武鸣人网站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> <div id="www_wuming_ren"> <div class="page"> <ul> <li><span>09-11-25</span><a href="https://www.wuming.ren" target="_blank">武鸣人一号文章</a></li> <li><span>09-11-25</span><a href="https://www.wuming.ren" target="_blank">武鸣人二号文章</a></li> <li style="background:coral;"><span>09-11-25</span><a href="https://www.wuming.ren" target="_blank">武鸣人三号文章</a></li> <li><span>09-11-25</span><a href="https://www.wuming.ren" target="_blank">武鸣人四号文章</a></li> <li><span>09-11-25</span><a href="https://www.wuming.ren" target="_blank">武鸣人五号文章</a></li> </ul> </div> <div class="page"> <ul> <li><span>09-11-25</span><a href="https://www.wuming.ren" target="_blank">武鸣人六号文章</a></li> <li><span>09-11-25</span><a href="https://www.wuming.ren" target="_blank">武鸣人七号文章</a></li> <li><span>09-11-25</span><a href="https://www.wuming.ren" target="_blank">武鸣人八号文章</a></li> <li><span>09-11-25</span><a href="https://www.wuming.ren" target="_blank">武鸣人九号文章</a></li> <li><span>09-11-25</span><a href="https://www.wuming.ren" target="_blank">武鸣人十号文章</a></li> </ul> </div> <div class="page"> <ul> <li><span>09-11-25</span><a href="https://www.wuming.ren" target="_blank">武鸣人十一号文章</a></li> <li><span>09-11-25</span><a href="https://www.wuming.ren" target="_blank">武鸣人十二号文章</a></li> <li><span>09-11-25</span><a href="https://www.wuming.ren" target="_blank">武鸣人十三号文章</a></li> <li><span>09-11-25</span><a href="https://www.wuming.ren" target="_blank">武鸣人十四号文章</a></li> <li><span>09-11-25</span><a href="https://www.wuming.ren" target="_blank">武鸣人十五号文章</a></li> <li><span>09-11-25</span><a href="https://www.wuming.ren" target="_blank">武鸣人十六号文章</a></li> </ul> </div> </div> </body> </html>
本文来自武鸣人网站,转载请注明出处