Safari in ios8 is scrolling screen when fixed elements get focus

前端 未结 12 1083
失恋的感觉
失恋的感觉 2020-12-12 11:24

In IOS8 Safari there is a new bug with position fixed.

If you focus a textarea that is in a fixed panel, safari will scroll you to the bottom of the page.

T

12条回答
  •  攒了一身酷
    2020-12-12 11:49

    I was able to fix this for select inputs by adding an event listener to the necessary select elements, then scrolling by an offset of one pixel when the select in question gains focus.

    This isn't necessarily a good solution, but it's much simpler and more reliable than the other answers I've seen here. The browser seems to re-render/re-calculate the position: fixed; attribute based on the offset supplied in the window.scrollBy() function.

    document.querySelector(".someSelect select").on("focus", function() {window.scrollBy(0, 1)});
    

提交回复
热议问题