大佬教程收集整理的这篇文章主要介绍了smoothscroll,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
smoothscroll是一款jQuery插件,可以平滑地滚动到指定的地方。
可以解决chrome锚点失效的问题。
官方网站 http://iamdustan.com/smoothscroll/
github地址 https://github.com/iamdustan/smoothscroll
h5代码:
<a href="javascript:void(0)" onclick="gotoTest1()">@L_674_5@</a>
JS代码
完整实例
<!doctype html> <html> <head> <Meta charset="UTF-8"> <Meta name="viewport" content="width=device-width,initial-scale=1"> <title>okayNav Demo</title> <link href="http://fonts.googleapis.com/css?family=Roboto:700,400&subset=laTin" rel="stylesheet" type="text/css"> <link rel="stylesheet" href="css/common.min.css"> <link rel="stylesheet" href="css/okayNav.min.css"> </head> <body> <header id="header" class="okayNav-header"> <a class="okayNav-header__logo" href="#"> logo </a> <nav role="navigation" id="nav-main" class="okayNav"> <ul> <li><a href="javascript:void(0)" onclick="gotoTest1()">@L_674_5@</a></li> <li><a href="javascript:void(0)" onclick="gotoTest2()">购物</a></li> <li><a href="javascript:void(0)" onclick="gotoTest3()">博客</a></li> <li><a href="javascript:void(0)" onclick="gotoTest4()">服务</a></li> <li><a href="javascript:void(0)" onclick="gotoTest5()">联系我们</a></li> <li><a href="javascript:void(0)" onclick="gotoTest6()">关于我们</a></li> <li><a href="javascript:void(0)" onclick="gotoTest7()">测试</a></li> </ul> </nav> </header><!-- /header --> <main> <h1 id="home" >Resize your browser to preview okayNav</h1> </main> <section id="shop" style="min-height:620px;BACkground-color:#777"> <h1 style="padding-top:100px;">shop</h1> </section> <section id="blog" style="min-height:620px;BACkground-color:#236777"> <h1 style="padding-top:100px;">blog</h1> </section> <section id="service" style="min-height:620px;BACkground-color:red"> <h1 style="padding-top:100px;">service</h1> </section> <section id="connect" style="min-height:620px;BACkground-color:#25fb65"> <h1 style="padding-top:100px;">connect</h1> </section> <section id="about" style="min-height:620px;BACkground-color:#66fb65"> <h1 style="padding-top:100px;">about</h1> </section> <section id="test" style="min-height:620px;BACkground-color:#e34565"> <h1 style="padding-top:100px;">test</h1> </section> <script src="https://code.jquery.com/jquery-2.2.3.min.js"></script> <script src="js/jquery.okayNav-min.js"></script> <script src="js/smoothscroll.js"></script> <script type="text/javascript"> var navigation = $(‘#nav-main‘).okayNav(); function gotoTest1(){ document.querySELEctor(‘#home‘).scrollIntoView({ behavior: ‘smooth‘ }); }function gotoTest2(){ document.querySELEctor(‘#shop‘).scrollIntoView({ behavior: ‘smooth‘ }); }function gotoTest3(){ document.querySELEctor(‘#blog‘).scrollIntoView({ behavior: ‘smooth‘ }); }function gotoTest4(){ document.querySELEctor(‘#service‘).scrollIntoView({ behavior: ‘smooth‘ }); }function gotoTest5(){ document.querySELEctor(‘#connect‘).scrollIntoView({ behavior: ‘smooth‘ }); }function gotoTest6(){ document.querySELEctor(‘#about‘).scrollIntoView({ behavior: ‘smooth‘ }); } function gotoTest7(){ document.querySELEctor(‘#test‘).scrollIntoView({ behavior: ‘smooth‘ }); } </script> </body> </html>
以上是大佬教程为你收集整理的smoothscroll全部内容,希望文章能够帮你解决smoothscroll所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。