Rob Rob - 1 year ago 110
CSS Question

Prevent background scrolling on open of lightbox

I'm using Featherlight as a lightbox. One problem I have is that went it opens, the background remains scrollable. A fix that most lightboxes need is adding a class to the body with

on it.

How can I do that on open of the lightbox, then remove the class on close?

Answer Source

You can use the options on your plugin call by using of the beforeOpen and afterClose options like:

$.featherlight($content, {
    beforeOpen: function() { = 'hidden';
    afterEnd: function() { = '';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download