zoukankan      html  css  js  c++  java
  • div跟随鼠标移动

    <!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=utf-8" /> <title>无标题文档</title> <style type="text/css">  *{ padding:0px; margin:0px; list-style:none;}  body{ height:1000px;}  #ul1 li{ position:absolute; 30px; height:30px; text-align:center; line-height:30px; border:1px solid red;}   </style> <script type="text/javascript">   window.onload=function()   {    setInterval(function(){    var oUl=document.getElementById('ul1');    var oLi=oUl.getElementsByTagName('li');    var i=0;    for(i=oLi.length-1;i>0;i--)    {     oLi[i].style.left=oLi[i-1].offsetLeft+35+"px";     oLi[i].style.top=oLi[i-1].style.top;    }},30);   };   document.onmousemove=function(ev)   {    var oEvent=ev||event;    var oUl=document.getElementById('ul1');    var oLi=oUl.getElementsByTagName('li');    var i=0;        for(i=oLi.length-1;i>0;i--)    {     oLi[i].style.left=oLi[i-1].offsetLeft+35+"px";     oLi[i].style.top=oLi[i-1].offsetTop+"px";     //oLi[i].style.marginLeft="10px;";    };    oLi[0].style.left=getEventX(oEvent)+"px";    oLi[0].style.top=getEventY(oEvent)+"px";   }      function getEventY(oEvent)   {    var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;        return oEvent.clientY+scrollTop;   }   function getEventX(oEvent)   {    var scrollLeft=document.documentElement.scrollLeft||document.body.scrollLeft;        return oEvent.clientX+scrollLeft;   }; </script> </head>

    <body> <h3>web前端开发交流群</h3> <p>149044724</p>  <ul id="ul1">      <li>1</li>         <li>8</li>         <li>7</li>         <li>0</li>         <li>1</li>         <li>4</li>         <li>6</li>         <li>1</li>         <li>4</li>         <li>8</li>         <li>3</li>     </ul> </body> </html>

  • 相关阅读:
    CDH中flume是已经启动着了…
    CDH中,执行HIVE脚本表联查权限问题。。
    linux screen 命令详解(未验证+研究)
    004ICMP-type对应表
    003iptables 命令介绍
    002利用zabbix监控某个目录大小
    Nginx图片剪裁模块探究 http_image_filter_module
    linux增加自定义path和manpath
    TortoiseSVN中图标的含义
    Linux SVN 搭建(YUM)安装
  • 原文地址:https://www.cnblogs.com/dearxinli/p/2853552.html
Copyright © 2011-2022 走看看