Last active
December 11, 2020 07:24
-
-
Save julian-stark/bdddc78107d18ba6b3d44b5c6d335261 to your computer and use it in GitHub Desktop.
Anchor link scrolls too deep?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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