简体   繁体   English

-webkit-overflow-scrolling打破绝对定位

[英]-webkit-overflow-scrolling breaks absolute positioning

I am building a page that needs to have some elements which stick to the top of the page when they would otherwise be scrolled off the screen. 我正在构建一个页面,当它们以其他方式滚动离开屏幕时,需要有一些元素粘在页面顶部。 I managed to do this using position:absolute . 我设法使用position:absolute来做到这一点。 Everything was working perfectly, but it needed momentum scrolling. 一切都很完美,但它需要动力滚动。 I added -webkit-overflow-scrolling: touch to the css of the scrollable area. 我添加了-webkit-overflow-scrolling: touch到可滚动区域的css。 This broke everything. 这打破了一切。 My sticky elements with position:absolute are now just scrolling with the rest of the content. 我的粘性元素与position:absolute现在只是滚动其余的内容。

My question is this: 我的问题是:

Why does -webkit-overflow-scrolling: touch affect absolute positioning, and is there a way around this? 为什么-webkit-overflow-scrolling: touch影响绝对定位,有没有解决方法?

UPDATE: I added an alert whenever a child element becomes "fixed" or "unfixed". 更新:每当子元素变为“固定”或“未固定”时,我都会添加警报。 The alerts continue to fire, so the styling is still being applied, it just isn't working. 警报继续触发,因此样式仍在应用,它只是不起作用。 This means that it's not a problem with keeping track of scroll position but rather a problem with the styling. 这意味着跟踪滚动位置不是问题,而是样式问题。

UPDATE: I tried using position: fixed instead of position: absolute and -webkit-overflow-scrolling broke that too 更新:我尝试使用position: fixed而不是position: absolute-webkit-overflow-scrolling破坏了它

UPDATE: After a lot of digging, I found references to this problem here and here . 更新:经过大量挖掘,我在这里这里找到了对这个问题的引用。 However, the only proposed solution in both cases is to restructure the DOM so that the sticky elements are not in the scrollable area. 但是,两种情况下唯一提出的解决方案是重构DOM,以便粘性元素不在可滚动区域中。 This is a difficult thing to do in my case, and I would prefer not to have to. 在我的情况下,这是一件很难的事情,我宁愿不必这样做。 Have things progressed since ios5 or is that still the only option? 自ios5以来有没有进展或者仍然是唯一的选择?

On the last question - yes the issue is present in ios5. 关于最后一个问题 - 是的,ios5中存在问题。 Extracting the absolute positioning element outside of the scrollable area worked fine for me. 在可滚动区域之外提取绝对定位元素对我来说很好。

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

相关问题 iOS:-webkit-overflow-scrolling:触摸和滚动 - iOS: -webkit-overflow-scrolling:touch and scrollTop 以编程方式停止-webkit-overflow-scrolling - Programmatically halt -webkit-overflow-scrolling -webkit-overflow-scrolling:自动; 在触控装置上无法运作 - -webkit-overflow-scrolling: auto; not working on touch devices 移动网络:-webkit-overflow-scrolling:触摸与位置冲突:已修复 - Mobile web: -webkit-overflow-scrolling: touch conflicts with position:fixed scrollLeft通过-webkit-overflow-scrolling自动返回到旧位置: - scrollLeft automatically returning to old position with -webkit-overflow-scrolling: touch JQueryUI可拖动加上-webkit-overflow-scrolling隐藏拖动元素吗? - JQueryUI draggable plus -webkit-overflow-scrolling hides dragging elements? 如何在react组件上设置-webkit-overflow-scrolling内联样式 - How to set -webkit-overflow-scrolling inline style on react component 任何方式应用'webkit-overflow-scrolling:touch'内嵌javascript? - Any way to apply 'webkit-overflow-scrolling: touch' inline with javascript? -webkit-overflow-scrolling:触摸导致jQuery动态更改不显示? - -webkit-overflow-scrolling: touch causes jQuery dynamic changes to not show? scrollTop不能与-webkit-overflow-scrolling一起使用:touch - scrollTop doesn't work with -webkit-overflow-scrolling: touch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM