JS 實現 Div 向上浮動


Html 及 JS 代碼如下:

<div id="newsOne" onmouseover="CleartTimeInterVal();" onmouseout="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>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM