Skip to content

Instantly share code, notes, and snippets.

@SiGaCode
Created January 20, 2018 14:29
Show Gist options
  • Save SiGaCode/ab45dcffc813aeca38230efc41b35999 to your computer and use it in GitHub Desktop.
Save SiGaCode/ab45dcffc813aeca38230efc41b35999 to your computer and use it in GitHub Desktop.
Set an offset for an onpage anchor, for example if a website has a fixed header and the first part of a paragraph gets hiden. Just add a class of "anchor" to the element in question. Credits: https://stackoverflow.com/questions/4086107/html-positionfixed-page-header-and-in-page-anchors
*.anchor:before {
display: block;
content: " ";
margin-top: -75px; // Set the Appropriate Height
height: 75px; // Set the Appropriate Height
visibility: hidden;
}
/* or */
*[id]:before {
display: block;
content: " ";
margin-top: -75px; // Set the Appropriate Height
height: 75px; // Set the Appropriate Height
visibility: hidden;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment