鼠标感应图层方块浮动特效

2个月前 (03-13 19:17)阅读67回复0
大陆
大陆
  • 管理员
  • 发消息
  • 注册排名1
  • 经验值4189
  • 级别管理员
  • 主题837
  • 回复2
楼主

一个鼠标感应图层上下浮动显示特效,只有用户的鼠标经过图层的时候才会触发,自定义浮动的幅度。

<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>


0
0
收藏0
回帖

鼠标感应图层方块浮动特效 期待您的回复!

取消
载入表情清单……
载入颜色清单……
插入网络图片

取消确定

图片上传中
编辑器信息
提示信息