简体   繁体   中英

colorbox jquery lightbox Scroll with parent window

I'm using the colorbox jquery lightbox.

I currently have the main window scroll disabled when the modal is open with

$(document).bind('cbox_open', function () {
    $('html').css({ overflow: 'hidden' });
}).bind('cbox_closed', function () {
    $.colorbox.remove();
    $('html').css({ overflow: 'auto' });
});

But i think that is not good enough.

I want it so that when the modal is open it transfer the scrolling from the modal to the main window

For example like bootstrap modal 3: http://jsfiddle.net/NUCgp/183/

Any help would be greatly appreciated.

Have you tried the scrolling option set to false?

If false, Colorbox will hide scrollbars for overflowing content. This could be used on conjunction with the resize method (see below) for a smoother transition if you are appending content to an already open instance of Colorbox.

From here: http://www.jacklmoore.com/colorbox/

The API also has a resize function. If you have dynamic content, you could resize the window to the size of the content which shouldn't cause any scrolling inside the lightbox.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM