position: fixed doesn't work on iPad and iPhone

后端 未结 15 2083
一整个雨季
一整个雨季 2020-11-22 16:16

I have been struggling with fixed positioning in iPad for a while. I know iScroll and it does not always seem to work (even in their demo). I also know that Sencha has a fix

15条回答
  •  轮回少年
    2020-11-22 16:39

    I had this problem on Safari (iOS 10.3.3) - the browser was not redrawing until the touchend event fired. Fixed elements did not appear or were cut off.

    The trick for me was adding transform: translate3d(0,0,0); to my fixed position element.

    .fixed-position-on-mobile {
      position: fixed;
      transform: translate3d(0,0,0);
    }
    

    EDIT - I now know why the transform fixes the issue: hardware-acceleration. Adding the 3D transformation triggers the GPU acceleration making for a smooth transition. For more on hardware-acceleration checkout this article: http://blog.teamtreehouse.com/increase-your-sites-performance-with-hardware-accelerated-css.

提交回复
热议问题