今天把导航栏固定了,想起增加滑动效果使之能够滚动到网页上部或下部。嘿嘿!不过在Google那搜索了一下。找了很久还是没找到,后来偶然的情况下发现了
xiaorsz写的文章,不过太复杂了,然后转到了popdo那里。发现这个方法简单!就用了这个方法!
我是在footer.php最底下加入这个代码
?Download download.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('a[href*=#]').click(function() { 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> |
在header.php页导航栏的层中加入以下代码:
?Download download.txt
1 2 | <div id="gotop"><a href="#page">Top</a></div> <div id="godown"><a href="#footer">Down</a></div> |
接下来就是css了自己写吧,我就不说明了!
效果就看我导航栏的效果了!Up Down
当然了还有留言也此有效果,不过在Opera上向上的没有滚动效果,不过还是能够链接过去.
感谢popdo

对《给主题增加滑动效果》评论