Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On Safari Mobile 10.3 sticky footer can be scrolled off the screen

Our mobile web application has sticky bottom navigation like the one you often find in iOS applications, and after Safari 10.3 release on landscape only it is possible to scroll sticky navigation (footer) off the screen. Even though it is position: fixed and set bottom: 0 it also wasn't possible on older Safari versions.

Styles for sticky nav / footer are following:

footer {   position: fixed;   height: 50px;   left: 0;   right: 0;   bottom: 0;   background: rgba(255, 0, 0, 0.7); } 

DEMO to try on phone

In portrait mode it is always visible:

portrait-mode

In landscape mode you can scroll it off screen for the size of top address bar:

enter image description here

Has anyone come across such issue? I would appreciate any help to make footer stay on the screen. Thanks

like image 273
Andriy Horen Avatar asked May 17 '17 15:05

Andriy Horen


2 Answers

There is nothing you can do about it. Safari's landscape mode makes the container with your content going off the screen. This is not detectable and therefore not to solve. I tried to illustrate what happens:

The blue bar = Safari's navigation bar

The yellow bar = Your app's navigation bar

Situation safari

Instead of shrinking the container's height, Safari lets it go off the screen.

like image 118
Thomas van Broekhoven Avatar answered Sep 29 '22 10:09

Thomas van Broekhoven


This is more a workaround than a real solution. However position: fixed has been a problem for mobile devices for years and the best way to overcome this problem is to use position: sticky.

sticky behaves like position: relative within its parent, until a given offset threshold is met in the viewport.

From: Stick your landings! position: sticky lands in WebKit

However position: sticky is not fully supported yet, so I would suggest to use also:

position: sticky; /* currently in development for MS Edge */ position: -webkit-sticky; position: -moz-sticky; position: -o-sticky; 

See status here for MS Edge sticky support status (thank you Frits)

enter image description here


html,  body {    height: 200%;  }    body {    background-image: linear-gradient(180deg, #ededed 0px, #ededed 9px, #000000 9px, #000000 10px);    background-size: 100% 10px;  }    footer {    position: sticky; /* currently in development for MS Edge */    position: -webkit-sticky;    position: -moz-sticky;    position: -o-sticky;    height: 50px;    top: 80%;    background: rgba(255, 0, 0, 0.7);  }
<!DOCTYPE html>  <html>    <head>    <meta charset="utf-8">    <meta name="viewport" content="width=device-width">    <title>JS Bin</title>  </head>    <body>    <footer>    </footer>  </body>    </html>
like image 32
Paolo Forgia Avatar answered Sep 29 '22 10:09

Paolo Forgia