Skip to content

Instantly share code, notes, and snippets.



Last active Dec 11, 2020
What would you like to do?
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