JS 实现 Div 向上浮动

[亡魂溺海] 提交于 2019-11-26 18:26:46

Html 及 JS 代码如下:

<div id="newsOne" οnmοuseοver="CleartTimeInterVal();" οnmοuseοut="resetInterVal();"
       style="position: absolute; width: 100px;">
       <a href="http://www.baidu.com" target="_blank">test Div</a>
   </div>
   <script type='text/javascript'>

       var newsOne = document.getElementById("newsOne");

       newsOne.style.bottom = 0;
       newsOne.style.left = window.screen.availWidth - 100;
       var bottom = 0;
       function newsScroll() {
           if (bottom > (window.screen.availHeight - window.screenTop)) {
                       bottom = 0;
               newsOne.style.bottom = 0;

           }
           else {

               bottom = bottom + 15;
               newsOne.style.bottom = bottom;
           }

       }


       var timeid = setInterval(newsScroll, 300);

       function CleartTimeInterVal() {
           clearInterval(timeid);
       }
       function resetInterVal() {
           timeid = setInterval(newsScroll, 300);
       }


   </script>

转载于:https://www.cnblogs.com/Roy_Cao/archive/2012/10/11/2719517.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!