偏移html锚以调整为固定的标头[重复]

北城余情 提交于 2020-08-08 19:25:21

问题:

This question already has an answer here: 这个问题已经在这里有了答案:

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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!