点击带锚点的网址后,如何让网页位置向下偏移一小段距离
参照 stackoverflow 的做法,在主体内容前加一个暗锚
<a class="target-fix"></a>
<artivle>主体内容...</article>
将锚点进行偏移,并隐藏占位:
.target-fix {
position: relative;
top: -44px; // 偏移值
display: block;
height: 0;
overflow: hidden;
}