Is there a Safari equivalent for scroll-behavior: smooth;?

前端 未结 3 535
无人及你
无人及你 2020-12-17 18:14

I\'m working on a single page portfolio which is navigated using a top-mounted navigation bar using href\'s. I use scroll-behavior: smooth; in my head\'s CSS an

3条回答
  •  情话喂你
    2020-12-17 18:56

    You can use -webkit-overflow-scrolling: touch;. No javascript required.

    Reference: https://css-tricks.com/snippets/css/momentum-scrolling-on-ios-overflow-elements/

    Edit: as pointed out I misunderstood the question (thanks for the comment). For scroll behavior in Safari there is no scape. You gotta use JavaScript. Here is a vanilla solution:

    https://perishablepress.com/vanilla-javascript-scroll-anchor/

提交回复
热议问题