how to make an element to be always on top? (z-index?) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how to make an element to be always on top? (z-index?)

how do you do it in elements/layouts such as navigation bar on top?

17th Oct 2016, 3:45 PM
Dax
1 Answer
+ 1
Hmm, it depends on what exactly you want to do. If you want to have a nav-bar on the top that stays there even when you scroll down, you'll want `position: fixed;`. Check out this example: <style> *{margin: 0; padding: 0;} nav{ width: 100vw; height: 100px; background: brown; position: fixed; top: 0; left: 0 } div{ height: 2000px; } </style> <nav></nav> <div></div>
17th Oct 2016, 4:00 PM
Schindlabua
Schindlabua - avatar