Linking to other sections of page with fixed Nav Bar/Header

Whatever section you link to on the page, your position would start there but not accounting the space the fixed Nav bar takes up (its height) since its z-index is greater. What should be shown on screen is covered by the Nav bar, so you start at a section below the area where you would want to.

Fix: add another <div> element right above the section where you want to go to. Set CSS properties to:

position: relative;     //position the <div> relative to its current position (itself)
top: -140px;             //represents the height of the Nav bar to account for its space it takes up

Original position remains in the flow of the document, just like the static value.

Positioning definitions: https://css-tricks.com/absolute-relative-fixed-positioining-how-do-they-differ/

Comments

Popular posts from this blog

Code Wars: Data Reverse (6 kyu)

Code Wars: longest_palindrome (6 kyu)

Code Wars: Find the odd int