原文出处:http://blog.csdn.net/kongjiea/article/details/45719213
【效果图】
【效果图】
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8" />
- <title>Document</title>
- <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
- <script>
- $(function(){
- //锚点跳转滑动效果
- $('a[href*=#],area[href*=#]').click(function() {
- console.log(this.pathname)
- if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
- var $target = $(this.hash);
- $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
- if ($target.length) {
- var targetOffset = $target.offset().top;
- $('html,body').animate({
- scrollTop: targetOffset
- },
- 1000);
- return false;
- }
- }
- });
- })
- </script>
- <style type="text/css" media="screen">
- .mk{height:500px;width:980px;border:1px solid #999;margin:auto;}
- .evt_nav_right{position:fixed;top:100px;right:10px;width:100px;}
- .evt_nav_right a{display:inline-block;width:100px;}
- </style>
- </head>
- <body>
- <div class="evt_nav_right" style="visibility: visible;">
- <a ytag="20054" href="#mk01" class="evt_link1" title="老乔经典">老乔经典</a>
- <a ytag="20055" href="#mk02" class="evt_link2" title="实时爆款">实时爆款</a>
- <a ytag="20056" href="#mk03" class="evt_link3" title="热销推荐">热销推荐</a>
- <a ytag="20057" href="#mk04" class="evt_link4" title="主流配件">主流配件</a>
- <a ytag="20058" href="#mk05" class="evt_link5" title="更多活动">更多活动</a>
- <a ytag="20059" href="javascript:void(0);" class="evt_link0" title="返回顶部">
- </a>
- </div>
- <div class="mk" id="mk01">mk01mk01</div>
- <div class="mk" id="mk02">mk02mk02</div>
- <div class="mk" id="mk03">mk03mk03</div>
- <div class="mk" id="mk04">mk04mk04</div>
- <div class="mk" id="mk05">mk05mk05</div>
- </body>
- </html>