本帖最后由 WADE_Design 于 2012-07-18 15:44:58 编辑

解决方案 »

  1.   

    那个遮盖的也设置position为fixed不就好了
      

  2.   

    有什么区别吗?
    fixed后是相对于当前视窗的,你需要加上视窗的scrollTop和scrollLeft而且你加了xhtml声明,document.body.onscroll要修改为document.documentElement.onscroll简单点就给window加onscroll window.onscroll = function () {
                        div.style.top = getOffset(fdiv).y + 'px';
                        div.style.left = getOffset(fdiv).x + 'px';
                    };function getOffset(a) {
                var b = a.offsetLeft, top = a.offsetTop, current = a.offsetParent,scroll=getScroll();
                while (current != null) {
                    b += current.offsetLeft;
                    top += current.offsetTop;
                    current = current.offsetParent;
                }
                return { x: b+scroll.sLeft, y: top +scroll.sTop};
            };