一个鼠标感应图层上下浮动显示特效,只有用户的鼠标经过图层的时候才会触发,自定义浮动的幅度。
<html> <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"> body { padding:0 40% 0 0; } #www_wuming_ren { width:200px; height:100px; text-align:center; background:#ccc; position:absolute; top:130px; right:20px; } </style> <script language="javascript" type="text/javascript"> function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); } } }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) 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.right) {//alert("ok"); elem.style.right = "20px"; } if (!elem.style.top) { elem.style.top = "130px"; } var xpos = parseInt(elem.style.right); 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; } if (ypos > final_y) { var dist = Math.ceil((ypos - final_y)/10); ypos = ypos - dist; } elem.style.right = xpos + "px"; elem.style.top = ypos + "px"; var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")"; elem.movement = setTimeout(repeat,interval); }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) function downwww_wuming_ren() { if (!document.getElementById) return false; if (!document.getElementById("www_wuming_ren")) return false; var list = document.getElementById("www_wuming_ren"); list.onmouseover = function() { moveElement("www_wuming_ren",20,150,10); } } addLoadEvent(downwww_wuming_ren); function upwww_wuming_ren() { if (!document.getElementById) return false; if (!document.getElementById("www_wuming_ren")) return false; var list = document.getElementById("www_wuming_ren"); list.onmouseout = function() { moveElement("www_wuming_ren",20,130,35); } }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) addLoadEvent(upwww_wuming_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">武鸣人提示您:<br />把鼠标移上来试试!</div> </body> </html>
本文来自武鸣人网站,转载请注明出处