Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fixed position footer scrolls in iPhone X

I have a hybrid HTML5 app created using the Trigger.io framework.

The app contains a fixed footer and a scrolling content area. The app works fine on all devices except the iPhone X. On the iPhone X when I scroll the content area, the footer actually scrolls out of view a little.

This is how the app looks when the footer is in view

Normal app view

But once I scroll down, the footer hides and only shows when I scroll up again.

Scrolled app view

I've applied the iPhone X optimizations for the notch and that works fine in the design. The only issue that remains is the scrolling problem.

Since I'm using a hybrid framework, the view is constructed with HTML + CSS and not native UI components.

Any thoughts on why the footer might be scrolling down on iPhone X?

like image 448
JohnP Avatar asked May 06 '18 20:05

JohnP


2 Answers

You could try placing the div outside of the scrollable part, and have the position fixed. So if you have a code where it scrolls,

<div id="scroll-container">
  <div id="scrollable">
  </div>
<div>

Such where any element in the div scroll-container, it will scroll.

If you place it outside of the scrollable part,

<div id="scroll-container">
<div>
<div id="not-scrollable">
</div>

and put position:fixed; or position:absolute; or position: sticky;(Brainfeeder)(I haven't tried it yet though) or device-fixed;(web-stars)(Haven't tried it either) in the css for #not-scrollable, It shouldn't scroll. Try it out.

Of course, this won't make it relative to the scrolling container, it will make it relative to whatever container it is in, and in this case, it is the body tag.

Note: I am just using a div as an example. You may use this any way you want

New: In the case that the body is your scroll, add a div inside the body tag but right after you declare the body tag so that the scroll is the div.

There are a bunch of sites that show you how to adopt a web page to iPhone X. Here's one of them.

like image 110
Random Channel Avatar answered Sep 27 '22 19:09

Random Channel


I used position:sticky; in previous web projects. Turns out it works in most cases. Can you use position sticky?

Another thing to try (I had to do this for FireFox and iOS Safari to fix some bugs) is to wrap the entire content in a <div>, including the fixed elements (header / footer, ...) Turned out they were fixed / sticky relative to their parent, once the parent ended, fixed and/or sticky broke resulting in various bugs.

If this simple fix does not work, I would go for the answer from @RandomChannel.

like image 20
Brainfeeder Avatar answered Sep 27 '22 19:09

Brainfeeder