html的锚链接位置偏差解决

使用锚链接,链接到位置有时有位置偏差

<script type="text/javascript">$(function(){

    var url = window.location.toString();

    var id = url.split("#")[1];

   if(id){

      var t = $("#"+id).offset().top-100;//位置偏差可调

      $(window).scrollTop(t);

   }

});

</script>

原文地址:https://www.cnblogs.com/deram/p/8259927.html