Fixed page header overlaps in-page anchors

前端 未结 30 2860
逝去的感伤
逝去的感伤 2020-11-22 00:25

If I have a non-scrolling header in an HTML page, fixed to the top, having a defined height:

Is there a way to use the URL anchor (the #fragment part) t

30条回答
  •  無奈伤痛
    2020-11-22 00:56

    You could try this:

    
    
    Go to bar
    
    

    Bar

    Set the top padding value to the actual height of your header. This will introduce a slight extra gap at the top of your header, but it will only be visible when the user jumps to the anchor and then scrolls up. I've made up that solution for my site right now, but it only shows a small fixed bar at the top of the page, nothing too high.

提交回复
热议问题