zoukankan      html  css  js  c++  java
  • JS 实现 Div 向上浮动

    Html 及 JS 代码如下:

    <div id="newsOne" onmouseover="CleartTimeInterVal();" onmouseout="resetInterVal();"
           style="position: absolute; 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>

  • 相关阅读:
    【树论】新二叉树
    【贪心】umi的函数
    【模拟】高精度练习之加法
    【模拟】高精度练习之减法
    【贪心】线段覆盖
    【树论】二叉树的序遍历
    【贪心】超级书架
    【动态规划】爱与愁的心痛
    【图论】牛大赛
    【图论】产生数
  • 原文地址:https://www.cnblogs.com/Roy_Cao/p/2719517.html
Copyright © 2011-2022 走看看