Scrolling to an Anchor using Transition/CSS3

前端 未结 10 899
-上瘾入骨i
-上瘾入骨i 2020-11-30 20:07

I have a series of links which are using an anchor mechanism:


      
10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-30 20:49

    If anybody is just like me willing to use jQuery, but still found himself looking to this question then this may help you guys:

    https://html-online.com/articles/animated-scroll-anchorid-function-jquery/

    $(document).ready(function () {
                $("a.scrollLink").click(function (event) {
                    event.preventDefault();
                    $("html, body").animate({ scrollTop: $($(this).attr("href")).offset().top }, 500);
                });
            });
    Scroll to anchor 1
    Scroll to anchor 2
    

    Anchor 1 - Lorem ipsum dolor sit amet, nonumes voluptatum mel ea.

    Anchor 2 - Ex ignota epicurei quo, his ex doctus delenit fabellas.

提交回复
热议问题