分享仿土豆网首页图片定时切换特效代码,在这个图片切换窗口的底部显示缩略图,实用的图片切换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" /> <title>仿土豆网首页js图片切换特效代码_武鸣人</title> <style type="text/css"> /* Reset style */ * { margin:0; padding:0; word-break:break-all; } body { background:#FFF; color:#333; font:12px/1.6em Helvetica, Arial, sans-serif; } h1, h2, h3, h4, h5, h6 { font-size:1em; } a { color:#039; text-decoration:none; } a:hover { text-decoration:underline; } ul, li { list-style:none; } fieldset, img { border:none; } em, strong, cite, th { font-style:normal; font-weight:normal; } /* www_wuming_ren style */ #www_wuming_ren { position:relative; width:450px; height:295px; overflow:hidden; margin:20px 0 1px 60px; } #www_wuming_ren_list { position:absolute; width:1800px; height:295px; } #www_wuming_ren_list li { float:left; } #www_wuming_ren_list li img { width:450px; height:295px; } .www_wuming_ren_opacity { position:absolute; width:450px; height:70px; top:225px; left:0; background:#000; filter:alpha(opacity=50); -moz-opacity:0.5; opacity: 0.5; } #www_wuming_ren_btn { position:absolute; width:450px; height:65px; top:225px; left:0; } #www_wuming_ren_btn ul { padding-left:5px; } #www_wuming_ren_btn li { display:inline; float:left; margin:0 15px; padding-top:12px; } #www_wuming_ren_btn li img { width:76px; height:50px; border:2px solid #888; } #www_wuming_ren_btn .current { background:url() no-repeat 37px 8px;} #www_wuming_ren_btn .current img { border-color:#EEE; } </style> <script type="text/javascript"> function $(id) { return document.getElementById(id); } function moveElement(elementID,final_x,final_y,interval) { if (!document.getElementById) return false; if (!document.getElementById(elementID)) return false; var elem = document.getElementById(elementID); if (elem.movement) { clearTimeout(elem.movement); } if (!elem.style.left) { elem.style.left = "0px"; } if (!elem.style.top) { elem.style.top = "0px"; } var xpos = parseInt(elem.style.left); var ypos = parseInt(elem.style.top); if (xpos == final_x && ypos == final_y) { return true; } if (xpos < final_x) { var dist = Math.ceil((final_x - xpos)/10); xpos = xpos + dist; } if (xpos > final_x) { var dist = Math.ceil((xpos - final_x)/10); xpos = xpos - dist; } if (ypos < final_y) { var dist = Math.ceil((final_y - ypos)/10); ypos = ypos + dist; }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) if (ypos > final_y) { var dist = Math.ceil((ypos - final_y)/10); ypos = ypos - dist; } elem.style.left = xpos + "px"; elem.style.top = ypos + "px"; var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")"; elem.movement = setTimeout(repeat,interval); } function classNormal(){ var focusBtnList = $('www_wuming_ren_btn').getElementsByTagName('li'); for(var i=0; i<focusBtnList.length; i++) { focusBtnList[i].className=''; } }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) function focusChange() { var focusBtnList = $('www_wuming_ren_btn').getElementsByTagName('li'); focusBtnList[0].onmouseover = function() { moveElement('www_wuming_ren_list',0,0,5); classNormal() focusBtnList[0].className='current' } focusBtnList[1].onmouseover = function() { moveElement('www_wuming_ren_list',-450,0,5); classNormal() focusBtnList[1].className='current' } focusBtnList[2].onmouseover = function() { moveElement('www_wuming_ren_list',-900,0,5); classNormal() focusBtnList[2].className='current' } focusBtnList[3].onmouseover = function() { moveElement('www_wuming_ren_list',-1350,0,5); classNormal() focusBtnList[3].className='current' } }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) setInterval('autoFocusChange()', 5000); var atuokey = false; function autoFocusChange() { $('www_wuming_ren').onmouseover = function(){atuokey = true} $('www_wuming_ren').onmouseout = function(){atuokey = false} if(atuokey) return; var focusBtnList = $('www_wuming_ren_btn').getElementsByTagName('li'); for(var i=0; i<focusBtnList.length; i++) { if (focusBtnList[i].className == 'current') { var currentNum = i; } } if (currentNum==0 ){ moveElement('www_wuming_ren_list',-450,0,5); classNormal() focusBtnList[1].className='current' } if (currentNum==1 ){ moveElement('www_wuming_ren_list',-900,0,5); classNormal() focusBtnList[2].className='current' } if (currentNum==2 ){ moveElement('www_wuming_ren_list',-1350,0,5); classNormal() focusBtnList[3].className='current' }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) if (currentNum==3 ){ moveElement('www_wuming_ren_list',0,0,5); classNormal() focusBtnList[0].className='current' } } window.onload=function(){ focusChange(); }//武鸣人网站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 id="www_wuming_ren_list" style="top:0; left:0;"> <ul> <li><a href="https://www.wuming.ren"><img src="/img/20240516_www_wuming_ren_36.jpg" alt="" /></a></li> <li><a href="https://www.wuming.ren"><img src="/img/20240516_www_wuming_ren_37.jpg" alt="" /></a></li> <li><a href="https://www.wuming.ren"><img src="/img/20240516_www_wuming_ren_38.jpg" alt="" /></a></li> <li><a href="https://www.wuming.ren"><img src="/img/20240516_www_wuming_ren_39.jpg" alt="" /></a></li> </ul> </div> <div class="www_wuming_ren_opacity"></div> <div id="www_wuming_ren_btn"> <ul> <li class="current"><a href="#"><img src="/img/20240516_www_wuming_ren_32.jpg" alt="" /></a></li> <li><a href="#"><img src="/img/20240516_www_wuming_ren_33.jpg" alt="" /></a></li> <li><a href="#"><img src="/img/20240516_www_wuming_ren_34.jpg" alt="" /></a></li> <li><a href="#"><img src="/img/20240516_www_wuming_ren_35.jpg" alt="" /></a></li> </ul> </div> </div><!--www_wuming_ren end--> <div style="height:20px; background:#EEE;"></div> </body> </html>
本文来自武鸣人网站,转载请注明出处