Scrolling slow on mobile/ios when using overflow:Scroll

前端 未结 1 1875
你的背包
你的背包 2020-12-07 12:48

To setup an off-canvas menu I have to set the body to \"overflow:hidden\" to remove scrolling from the body and add it back in to a container around the content with \"overf

1条回答
  •  醉梦人生
    2020-12-07 13:21

    Rather than a performance issue this is likely that your not seeing 'Momentum' scrolling on your iOS device

    This can be solved by adding '-webkit-overflow-scrolling:touch' to your scrolling element i.e:

    .scrolling-content {
       overflow-y: scroll;
       -webkit-overflow-scrolling: touch;
       height:100%; /*A value other than height:auto needs to be set*/
    }
    

    By default iOS devices use 'momentum' scrolling on the body but adding 'overflow-y:scroll' to an element does Not set a element to 'momentum' scrolling by default

    See https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-overflow-scrolling for more info

    Note: there's a number of Gotcha/Bugs with using -webkit-overflow-scrolling: touch on certain browsers

    0 讨论(0)
提交回复
热议问题