本文介绍了当出现灯箱时阻止滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上使用的Lightbox灯箱脚本。有什么办法可以在灯箱出现时阻止主页上的滚动并在它消失时解锁?



或者,也许您可​​以建议更好的Lightbox脚本?



谢谢。

解决方案

用户可以禁用或启用窗口滚动条:

  document.body.style.overflow =hidden; 

显示您的灯箱和

  document.body.style.overflow = 可见; 

隐藏您的灯箱。



但如果你真的想找一个更好的灯箱库,你可以试试这个jQuery插件: b
$ b


I use DOM window script for Lightboxes on my website. Is there any way to block scroll on main page when Lightbox appears and unblock when it disappears?

Or, maybe, you can advice better Lightbox script?

Thanks.

解决方案

User this to disable or enable window scrollbar :

document.body.style.overflow="hidden";

on show your lightbox and

document.body.style.overflow="visible";

on hiding your lightbox.

but if your are really looking for a better lightbox library you can try this jQuery plugin :

jQuery Lightbox Plugin

这篇关于当出现灯箱时阻止滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 23:02