Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fixed elements aren't clickable when I quickly scroll to the bottom in iOS Safari 9+

I've run into a very annoying issue only on iOS Safari 9+ (8.4 is fine) where, once the user quickly scrolls a page resulting in anchor links within fixed elements no longer being clickable due to the appearance and actual click/hit area not lining up with its element until the user scrolls again.

It doesn't happen the same way every time, and can take a few tries to "break" the system. Content must be longer than the viewport for this to work.

iOS 9+ Safari Fixed:Position Scroll Issue Screen Recording

No workarounds to the problem yet. How can I solve this issue?

UPDATE: After further testing, the issue only happens with iOS Safari 9 and above, tested on iOS 8 and there is no problem.

UPDATE 2: It's now clear that this happens on most websites using position:fixed; and even position:-webkit-sticky;. You may want to check yours :)

HTML

<section>
  <article></article>
  <article></article>
  <article></article>
</section>

<div class="sticky">
  <a href=""></a>
</div>

CSS:

html, body {
  margin:0;
}

article {
  display: block;
  height: 200px;
  width: 100%;
  margin-bottom: 20px;
  background: whitesmoke;
}

.sticky {
  width:100%;
  height:100px;
  position: fixed;
  bottom:0;
  background: orange;
  text-align:center;

}

.sticky a {
  display: inline-block;
  width: 100px;
  height: 100px;
  background: yellow;
}

http://codepen.io/toobulo/pen/dGEodo

The issue doesn't happen within Codepen editor, as it's related to mobile Safari's elastic / toolbar size changes. Please export code into own page, or use the following link:

https://cdn.rawgit.com/anonymous/3234ad797dd80e5f8905/raw/ab51c4d8621cfb827f83a33d21940579f8682cde/index.html

like image 990
Joe Avatar asked Feb 11 '16 07:02

Joe


People also ask

How we fix the Webkit overflow scrolling touch bug IOS?

The solution I found was to remove all the CSS that tricks the browser into using the GPU: -webkit-transform: translateZ(0px); -webkit-transform: translate3d(0,0,0); -webkit-perspective: 1000; By doing this, the '-webkit-overflow-scrolling: touch;' can still be included and still function as normal.

Why does Safari scroll to the bottom?

It may be so that Safari doesn't allow javascript in search/address-bar. You have to create a bookmark, doesn't matter what's in it. Then you edit it, paste the javascript-line to where the url is supposed to be, and save it.


1 Answers

This problem is related to the bounce effect in ios and losing the toolbar & the header bar. The only way that i have found to fix this is to do the following:

html,
body {
  height: 100%;
  width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: auto
}

You could do it on a breakpoint as well so it only works for mobile. Hope this helps.

** Added the overflow scrolling.

like image 181
andy jones Avatar answered Oct 19 '22 14:10

andy jones