小编tom*_*teg的帖子

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

我们使用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'
    }
  }
};
Run Code Online (Sandbox Code Playgroud)

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

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

.fancybox-overlay {
overflow: hidden !important;
}
Run Code Online (Sandbox Code Playgroud)

jquery fancybox fancybox-2

14
推荐指数
3
解决办法
4万
查看次数

标签 统计

fancybox ×1

fancybox-2 ×1

jquery ×1