如何设置禁止蒙层底部页面不随滚动而移动?

2026-04-06 19:292阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计219个文字,预计阅读时间需要1分钟。

如何设置禁止蒙层底部页面不随滚动而移动?

打开文件 `gistfile1.txt`,内容如下:

如何设置禁止蒙层底部页面不随滚动而移动?

Document 打开弹窗 关闭弹窗 // .stopBodyScroll.jslet _stopBodyScroll={ options: { bodyEl: document.body, topIndex: 0 }, init: function(isFixed) { if (isFixed) { this.options.topIndex=window.scrollY; this.options.bodyEl.style... } }}

gistfile1.txt

Document 打开弹窗 // ./stopBodyScroll.js let _stopBodyScroll = { options: { bodyEl: document.body, topIndex: 0 }, init: function(isFixed) { if (isFixed) { this.options.topIndex = window.scrollY this.options.bodyEl.style.position = 'fixed' this.options.bodyEl.style.top = -this.options.topIndex + 'px' } else { this.options.bodyEl.style.position = '' this.options.bodyEl.style.top = '' window.scrollTo(0, this.options.topIndex) // 回到原先的top } } }

本文共计219个文字,预计阅读时间需要1分钟。

如何设置禁止蒙层底部页面不随滚动而移动?

打开文件 `gistfile1.txt`,内容如下:

如何设置禁止蒙层底部页面不随滚动而移动?

Document 打开弹窗 关闭弹窗 // .stopBodyScroll.jslet _stopBodyScroll={ options: { bodyEl: document.body, topIndex: 0 }, init: function(isFixed) { if (isFixed) { this.options.topIndex=window.scrollY; this.options.bodyEl.style... } }}

gistfile1.txt

Document 打开弹窗 // ./stopBodyScroll.js let _stopBodyScroll = { options: { bodyEl: document.body, topIndex: 0 }, init: function(isFixed) { if (isFixed) { this.options.topIndex = window.scrollY this.options.bodyEl.style.position = 'fixed' this.options.bodyEl.style.top = -this.options.topIndex + 'px' } else { this.options.bodyEl.style.position = '' this.options.bodyEl.style.top = '' window.scrollTo(0, this.options.topIndex) // 回到原先的top } } }