New Fixed position bug on iOS8

こ雲淡風輕ζ 提交于 2019-11-29 09:52:30

A little late to the party, but adding

html, body {
    overflow-x: hidden;
    overflow-y: scroll;
}

Will fix the offset scrolling on fixed elements that are offset (eg. left:20px) in iOS 8.

I had a similar issue on iOS using multiple fixed position elements and a CSS animated off-canvas nav. On a long page the upward "drift" was a blocker because it eventually increased to the point where it hid the nav trigger, making it impossible to close the menu. I tried extensively to find a fix and settled on a workaround: scroll back to top before animating. (#ocnTrigger is my off-canvas menu trigger.)

$('#ocnTrigger').click(function(){
    $('body').animate({
      scrollTop: 0
    }, 0);
});
iX3

I was trying to do something similar (see here and here) then found that Apple has published a technical note recommending that fixed positioning be avoided. I swear it worked fine in iOS 7, but now with iOS8 it no longer "sticks".

This problem seems closely related to setting this meta tag:

    <meta name="viewport" content="width=device-width">

See also: Fix div to bottom without using css position

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!