利用锚点改变事件\(onhashchange\),使用jQuery的\(scrollTop\)向前滚回导航栏的高度(比如我的100个像素)
HTML:

<body onhashchange="fix_the_nav();">
</body>

js:

function fix_the_nav() {
    if(window.location.hash){
            var target = $(location.hash);
            $("body,html").scrollTop(target.offset().top-100); // my nav size is 100px
    }
}

Done.

我的Gist

相关文章:

  • 2022-12-23
  • 2021-04-13
  • 2021-05-06
  • 2022-12-23
  • 2021-11-23
  • 2021-07-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
  • 2021-10-08
  • 2022-12-23
相关资源
相似解决方案