简体   繁体   English

溢出隐藏文档的滚动偏移

[英]Scroll Offset of Overflow Hidden Document

CSS CSS

html, body {
  width: 100%;
  overflow-x: hidden
}

Setting above CSS in a page removes scroll from window [but triggers it on body], hence在页面中设置上面的 CSS 会从窗口中删除滚动 [但在正文上触发它],因此

 pageOffset =  (window.pageYOffset && { X: window.pageXOffset, Y: window.pageYOffset }) || {},
 dElementOffset = (dE && { X: dE.scrollLeft, Y: dE.scrollTop }) || {},
 dBodyOffset = (dB && { X: dB.scrollLeft, Y: dB.scrollTop }) || {};

[db = document.body, dE = document.documentElement] [db = document.body, dE = document.documentElement]

None of the above code gives the number of pixels scrolled.上面的代码都没有给出滚动的像素数。 Is there a way to determine scroll values in such cases?在这种情况下,有没有办法确定滚动值? http://jsbin.com/zayem/1/edit?html,css,js,console,output [Need to load it in a separate html file; http://jsbin.com/zayem/1/edit?html,css,js,console,output 【需要在单独的html文件中加载; Linked it just for understanding]链接它只是为了理解]

document.documentElement.scrollLeft works for me. document.documentElement.scrollLeft对我有用。 I tested it.我测试了它。

Also, your resizing columns are lagging.此外,您调整大小的列滞后。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM