how to prevent scrolling of page behind fancybox-2

前端 未结 9 1955
北恋
北恋 2020-12-16 14:44

We are using fancybox2 for displaying images. Everything works well, but when the larger image is displayed in the fancybox, the page behind scrolls to the top. After closin

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-16 14:53

    My modification, this help me

    /* Fancybox */
    $('.fancybox').fancybox({
        beforeShow: function(){
            $("body").css({
                "overflow-y": "hidden",
                "position": "fixed"
                }
            );
        },
        afterClose: function(){
            $("body").removeAttr("style");
        }
    });
    

提交回复
热议问题