Lock an Element to the Browser Window with Fixed Positioning
Summary
The fixedposition property locks an element relative to the browser window.
Removes the element from the normal flow of the document.
Elements with a fixed position won’t move when the user scrolls.
Final Code
<style>body{min-height:150vh;}#navbar{position:fixed;top:0;left:0;width:100%;background-color:#767676;}navul{margin:0px;padding:5px0px5px30px;}navli{display:inline;margin-right:20px;}a{text-decoration:none;}</style><body><header><h1>Welcome!</h1><navid="navbar"><ul><li><ahref="">Home</a></li><li><ahref="">Contact</a></li></ul></nav></header><p>I shift up when the #navbar is fixed to the browser window.</p></body>