Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
567 views
in Technique[技术] by (71.8m points)

jquery - Tag html width overflow-y and fancybox scroll

I apologize in advance for possible mistakes in English.

My question is next. In my style.css, html tag have propertie overflow-y:scroll. Farther i'm connect fancybox v3. When i call fancy modal, it is opened correct. But window doesn't fixed by center, because fancy inherite overflow-y:scroll from html tag. How do i fix this? When fancy is opened scrollbars should don't show to me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could simply change the CSS-definition via jQuery or something when opening the modal, then revert to "scroll" when closing it. Something like this...

$('[data-fancybox]').fancybox({
    afterShow: function( instance, slide ) {

        $('html').css('overflow-y','inherit');

    },
    afterClose: function( instance, slide ) {

        $('html').css('overflow-y','scroll');

    }
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...