Skip to content

Instantly share code, notes, and snippets.

@jonnymaceachern
Last active September 3, 2015 18:54
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 jonnymaceachern/1a78d9e895066b7dcd97 to your computer and use it in GitHub Desktop.
Save jonnymaceachern/1a78d9e895066b7dcd97 to your computer and use it in GitHub Desktop.
Adds an offset when jumping to a pages anchor/id to account for a fixed header that may overlap the content.
/* When using a fixer header that takes up the top 100px
or so, you can offset the anchor jump using the following */
.offset-anchor:before {
display: block;
content: " ";
height: 100px; /* Give height of your fixed element */
margin-top: -100px; /* Give negative margin of your fixed element */
visibility: hidden;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment