Skip to content

Instantly share code, notes, and snippets.

@julian-stark
Last active December 11, 2020 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save julian-stark/bdddc78107d18ba6b3d44b5c6d335261 to your computer and use it in GitHub Desktop.
Save julian-stark/bdddc78107d18ba6b3d44b5c6d335261 to your computer and use it in GitHub Desktop.
Anchor link scrolls too deep?
/**
* If #anchor link scrolls to deep -> e.g. heading is hidden by sticky header
**/
h2 {
/* margin: 20px 0; Let's imagine h2 has margin-top of 20px */
padding-top: 100px; /* new padding-top = height element should be moved down in scroll (e.g. sticky header height) */
margin-top: -80px; /* new margin top = old margin-top - new padding-top */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment