html

<a href="#maodian">点这里跳</a>
<div id="maodian">跳到这里</div> 

js+jquery

window.onhashchange=function(){
    var target = $(location.hash);
    if(target.length==1){
        var top = target.offset().top-120;// 距离顶部120像素
        if(top > 0){
            $('html,body').animate({scrollTop: top}, 1000);//带jq动画的跳转
           //$('html,body').css({scrollTop: top}) //不带jq动画的跳转
        }
    }
};