/* #navbar is the topmost element and <main> contains all other content */ #navbar { /* CSS property ensuring #navbar always stays in the same place even if the page is scrolled: */ position: fixed; } main { /* Ensure the remaining content doesn't hide behind the #navbar: */ position: absolute; z-index: 1; top: 100px; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter