Fixed persistent header and scroll to focussed input fields

前端 未结 1 650
星月不相逢
星月不相逢 2021-01-01 13:32

QUESTION: Based on the given examples for homescreen web apps in iOS7 Safari, how can I achieve both a fixed persistent header that never scrolls out of view, and fo

1条回答
  •  囚心锁ツ
    2021-01-01 14:13

    You should check out this answer - fixed position div freezes on page (iPad)

    And here is a really good article by Brad Frost that I've desperately read through a few times myself over the years hoping for an answer to this dilemma. - https://bradfrost.com/blog/post/fixed-position/

    It answers what you're asking pretty thoroughly. Fixed positioning is broken on mobile, it can be massaged with JS, but not really even completely fixed.

    You can fix one problem, your "header glitch" in demo 2 is just the fixed header hiding behind the absolutely positioned #page. Give your header a z-index of 1+ and that will fix that issue.

    As far as the header losing positioning when the keyboard comes in; I'm not even sure that's actually a bug, just the nature of the browser. What's happening is that the keyboard is gaining focus, at that point you're now dealing with ios' UI not the web browser and everything in the background is freezing (including fixed positioned elements and all other elements). Notice how the entire screens scrolls, that's not a web feature it's a built in browser feature.

    0 讨论(0)
提交回复
热议问题