gpt4 book ai didi

jquery - 如何防止fancybox-2后面的页面滚动

转载 作者:行者123 更新时间:2023-12-03 21:59:23 24 4
gpt4 key购买 nike

我们使用 fancybox2 来显示图像。一切都运行良好,但是当较大的图像显示在 fancybox 中时,后面的页面会滚动到顶部。关闭 fancybox 后,用户必须向下滚动回到打开该框的位置。 fancybox2 网站上的示例未显示此行为。我无法找出实现这种情况的区别在哪里。

fancyOptions = {
type: 'image',
closeBtn: false,
autoSize: false,
scrolling: 'no',
type: 'image',
padding: [10,10,10,10],
beforeLoad: function(){
this.title = getTitle(this);
this.href = $(this.element).closest('a').attr('href');
},
helpers: {
overlay: {
css: {
'background': 'rgba(0, 0, 0, 0.7)'
},
},
title: {
type: 'inside'
}
}
};

我们使用 fancybox2 作为 require.js 中的模块。.fancybox() 调用位于 $(document).ready block 中。

那里有 2 个滚动条,我用 css 隐藏了一个

.fancybox-overlay {
overflow: hidden !important;
}

最佳答案

显然,当显示图片时,Fancybox 会将 body 元素上的 CSS 属性 overflow 更改为 hidden。这会导致背景滚动回顶部。您所要做的就是注释掉样式表 jquery.fancybox.css.fancybox-lock 部分中的 overflow: hide !important; 行>.

请参阅fancybox2 / fancybox causes page to to jump to the top也是如此。

关于jquery - 如何防止fancybox-2后面的页面滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15631124/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com