问题:
This question already has an answer here: 这个问题已经在这里有了答案:
- Fixed page header overlaps in-page anchors 32 answers 固定页面标题与页面内定位点重叠 32个答案
I am trying to clean up the way my anchors work. 我正在尝试清理锚点的工作方式。 I have a header that is fixed to the top of the page, so when you link to an anchor elsewhere in the page, the page jumps so the anchor is at the top of the page, leaving the content behind the fixed header (I hope that makes sense). 我有一个固定在页面顶部的标题,因此当您链接到页面其他位置的锚点时,页面会跳转,因此该锚点位于页面顶部,而将内容留在固定的标题后面(我希望那讲得通)。 I need a way to offset the anchor by the 25px from the height of the header. 我需要一种将锚点从标头高度偏移25像素的方法。 I would prefer HTML or CSS, but Javascript would be acceptable as well. 我更喜欢HTML或CSS,但是Javascript也可以接受。
解决方案:
参考一: https://stackoom.com/question/j23u/偏移html锚以调整为固定的标头-重复参考二: https://oldbug.net/q/j23u/offsetting-an-html-anchor-to-adjust-for-fixed-header-duplicate
来源:oschina
链接:https://my.oschina.net/u/4432649/blog/4313384