<!doctype html> <html> <head> <meta charset="utf-8"> <title>单页切换</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> </head> <body> <script> $(function(){ $("#control a").click(function(){ var rel=$(this).attr("href"); var pos=$(rel).offset().top; $("html,body").animate({scrollTop:pos}, 800); }) }) </script> <div id="control" style="position:fixed;top:0px;"> <a href="#top">head</a><br/><a href="#center">middle</a><br/><a href="#bottom">bottom</a> </div> <div id="top" style="height:700px;background:#f00"> </div> <div id="center" style="height:700px;background:#ff0"> </div> <div id="bottom" style="height:700px;background:#0ff"> </div> </body> </html>