position: fixed , has a very bad performance on mobile/tablet devices when scrolling
Asked Answered
D

3

9

I'm using position: fixed in my site to fix the navigation bar in the view port, just like facebook's blue bar, but when we tried it on mobile/tablet devices (with their low processing powers) this fixed-bar makes a very bad hit on performance, which makes a very bad user experience when scrolling,

we used a very good articles to enhance the scrolling, and indeed they did, like:

After a lot of modifications based on these articles, we reached to the point where position: fixed is the only investigation left for us to enhance in.

The site has an ultra-smooth scrolling when we change it to position: absolute. But with fixing it, the scrolling has a very bad drawback to the extent that it could hang the safari browser on ipad when scrolling in a certain way, did you know how to use position: fixed with a good performance on tablet/mobile devices?

Dawna answered 1/7, 2013 at 17:30 Comment(0)
S
7

If your "tablet/mobile devices", which have performance problem, have a Webkit engine you probably could find answer here: Chrome slow scrolling with fixed position elements

Fast answer: try to add -webkit-transform: translateZ(0); on fixed block.

Stilbite answered 4/9, 2013 at 8:4 Comment(1)
If you have a problem of footer (position:fixed) "following you" using -webkit-transform: translateZ(0); solves it (at least in Android < 2.2). THANKs!!!Eoin
B
7

In order to get a smooth scrolling in mobile device, also when having "position: absolute",

you only need to add to the Div the css attribute

-webkit-overflow-scrolling: touch;

Batik answered 23/6, 2014 at 15:54 Comment(2)
This does seem to improve performance quite a bit, though child elements with position:fixed seem to have very poor performance in mobile safariAlbacore
This fixed my problem where I needed a div with height: 100% and position: fixed. Without that CSS scrolling was glitchy and with it I'm golden.Guenon
C
3

Now you can use "position: sticky"

Cowbane answered 24/7, 2020 at 17:34 Comment(2)
What would be the performance difference between the 2?Dawna
Sticky is best... the motion is flawless... check this TABLE on mobile view: genevo.com/cz/srovnani-detektoru ... if you horizontally scroll it will stick the left columnsHypertrophy

© 2022 - 2024 — McMap. All rights reserved.