div随页面滚动 位置固定问题js代码discuz教程
类别:建站知识   时间:10-12

div随页面滚动位置固定,但是当碰到下方一个div块后结束固定,请教老大解决,下面是js代码,我试了下,固定的div会穿过下方的div,不好看.

<script type="text/javascript">    window.onload=        function(){            var oDiv = document.getElementById("fixPara"),                H = 0,                Y = oDiv                    while (Y) {                H += Y.offsetTop;                 Y = Y.offsetParent;            }            window.onscroll = function()            {                var s = document.body.scrollTop || document.documentElement.scrollTop                if(s>H) {                    oDiv.style = "position:fixed;top:60px;left: 963px;"                } else {                    oDiv.style = "position:static;"                }            }        }</script>


智慧半岛,是一家专注于青岛网站建设青岛网站开发的青岛网络公司,Copyright ©2007-2019 Ebandao.Cn 版权所有 All Rights Reserved.(建议在1366x768以上的浏览器中访问)鲁ICP备08014496号

13153297890