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> |