通过滚动条向下滚动时,DIV广告自动跟着向下滚动,并且点击置顶

    xiaoxiao2025-10-13  3

    <html> <head>     <title></title>     <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>     <style type="text/css">         .div1         {             height: 2000px;         }         .div2         {             width: 200px;             height: 200px;             margin-top: 100px;         }         .div2_1         {             position: fixed;             width: 200px;             height: 200px;             z-index: 999;             background-color: #3399FF;             top: 0px;             _position: absolute;             _bottom: auto;             _top: expression(eval(document.documentElement.scrollTop));         }             </style>     <script>         $(function () {             $("#top").click(function () { $('html,body').animate({ scrollTop: '0px' }, 1000); return false; });                    })     </script>     <script type="text/javascript">         window.onscroll = function () {             var t = document.documentElement.scrollTop || document.body.scrollTop;             var div2 = document.getElementById("div2");             if (t >= 100) {                 div2.className = "div2_1";             } else {                 div2.className = "div2";             }         }             </script> </head> <body>     <div class="div1">         <div id="div2" class="div2">             <div id="top" style="width: 200px; height: 100px; background-color: Black;">             </div>                    </div>     </div> </body> </html>

    转载请注明原文地址: https://ju.6miu.com/read-1303127.html
    最新回复(0)