IE9 strange position fixed issue

时光毁灭记忆、已成空白 提交于 2019-12-11 15:46:32

问题


If you go here, while scrolling down the page you will notice that the right panel containing shopping and categories is moving along also...

I use this script for this:

 $(function () {
    var btn = $('.scroll');
    var btnPosTop = btn.offset().top;
    var win = $(window);
    win.scroll(function (e) {
        var scrollTop = win.scrollTop();
        if (scrollTop >= btnPosTop) {
            btn.css({ position: 'fixed', top: 10, marginTop: 0, 'z-index': 1, width: '260px'});
        } else if (btn.css('position') === 'fixed') {
            btn.css({ position: '', top: '', marginTop: '0px', 'z-index': 0 });
        }
    });
});

All works nice except that in IE 9, the div is no longer shown while scrolling down(oh, right, it is there but is not visible).

As you can notice, I've even tried to use z-index in the above script hoping that this will fix the issue, but it's in vain.

Can you guys suggest a solution?


回答1:


Add a position : relative to your #sidebar.

z-index only works when position is not static.



来源:https://stackoverflow.com/questions/9546975/ie9-strange-position-fixed-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!