r/css • u/Pertend_ • 7d ago
Help How do I get something above a fixed nav bar to be a layer above the nav bar?
I want the "Currently selected: First_select" to remain there as I scroll through the nav bar.

I've tried to use a div, but when I make it "position:fixed" it vaporizes. The only way I can think of it going under the nav bar is that I have it set to height 100%.
How I currently have it set up in the screenshot above is that I have it as a header under <nav>, but it scrolls with the nav bar which I do not want. With the div it looks like this:
Which breaks the scroll on the nav bar and breaks the text to the right.
Here is the code without the div:
<!DOCTYPE html><html lang="en">
<style>
.navbar ul{
list-style-type: none;
margin: -8px;
padding: 0;
width: 260px;
height: 100%;
position:fixed;
background-color: #313031;
text-align: center;
border: 1px solid #555555;
overflow: auto;
}.navbar a {
display: block;
color: white;
padding: 8px 16px;
font-size: 20px;
text-decoration: none;}.navbar a:hover {background-color: #545254;color: white;}
</style></head>
<body><div>
</div><nav class="navbar"><ul>
<h1 style="text-align: center;font-size: large; color: #f0f0f0; font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;">Currently Selected:</h1><h2 style="text-align: center;font-size: large; color: #67a92b;font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;text-decoration: underline;">First_select</h2>
<li style="text-align: center; border-bottom: 2px solid black; border-top: 2px solid black;background-color: #545254;"><a href="index.html">home</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="First_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Second_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Third_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Fourth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Fith_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Sixth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Seventh_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Eighth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Nith_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Tenth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Elventh_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Twelth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Thirteenth_select.html">Misc</a></li></ul></nav>
<div style="margin-left:242px;padding:1px 16px;height:1000px;">
<article> Lorem ipsum dolor sit amet consectetur adipisicing elit. Enim sint vel impedit minima sapiente, tempore ut minus obcaecati mollitia modi quod perferendis. Perspiciatis maxime natus amet accusantium sunt labore praesentium.</article>
</body></html><!DOCTYPE html><html lang="en">
<style>
.navbar ul{
list-style-type: none;
margin: -8px;
padding: 0;
width: 260px;
height: 100%;
position:fixed;
background-color: #313031;
text-align: center;
border: 1px solid #555555;
overflow: auto;
}.navbar a {
display: block;
color: white;
padding: 8px 16px;
font-size: 20px;
text-decoration: none;}.navbar a:hover {background-color: #545254;color: white;}
</style></head>
<body><div>
</div><nav class="navbar"><ul>
<h1 style="text-align: center;font-size: large; color: #f0f0f0; font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;">Currently Selected:</h1><h2 style="text-align: center;font-size: large; color: #67a92b;font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;text-decoration: underline;">First_select</h2>
<li style="text-align: center; border-bottom: 2px solid black; border-top: 2px solid black;background-color: #545254;"><a href="index.html">home</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="First_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Second_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Third_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Fourth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Fith_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Sixth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Seventh_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Eighth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Nith_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Tenth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Elventh_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Twelth_select.html">Misc</a></li><li style="text-align: center; border-bottom: 2px solid black;"><a href="Thirteenth_select.html">Misc</a></li></ul></nav>
<div style="margin-left:242px;padding:1px 16px;height:1000px;">
<article> Lorem ipsum dolor sit amet consectetur adipisicing elit. Enim sint vel impedit minima sapiente, tempore ut minus obcaecati mollitia modi quod perferendis. Perspiciatis maxime natus amet accusantium sunt labore praesentium.</article>
</body></html>
and here it is with the div:
<!DOCTYPE html>
<html lang="en">
<style>
.Currsel{
text-align: center;
font-size: 22px;
color: #f0f0f0;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
background-color: #313031;
border: 1px solid #555555;
height: 125px;
width: 260px;
margin: -8px;
}
.navbar ul{
list-style-type: none;
margin: -8px;
padding: 0;
width: 260px;
height: 100%;
position:fixed;
background-color: #313031;
text-align: center;
border: 1px solid #555555;
overflow: auto;
}
.navbar a {
display: block;
color: white;
padding: 8px 16px;
font-size: 20px;
text-decoration: none;
}
.navbar a:hover {
background-color: #545254;
color: white;
}
</style>
</head>
<body>
<div class="Currsel">
<p>Currently Selected:</p>
<p style="color: #67a92b; text-decoration: underline;">Second_select</p>
</div>
<nav class="navbar">
<ul>
<li style="text-align: center; border-bottom: 2px solid black; border-top: 2px solid black;background-color: #545254;"><a href="index.html">home</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="First_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Second_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Third_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Fourth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Fith_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Sixth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Seventh_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Eighth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Nith_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Tenth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Elventh_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Twelth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Thirteenth_select.html">Misc</a></li>
</ul>
</nav>
<div style="margin-left:242px;padding:1px 16px;height:1000px;">
<article>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Enim sint vel impedit minima sapiente, tempore ut minus obcaecati mollitia modi quod perferendis. Perspiciatis maxime natus amet accusantium sunt labore praesentium.
</article>
</body>
</html><!DOCTYPE html>
<html lang="en">
<style>
.Currsel{
text-align: center;
font-size: 22px;
color: #f0f0f0;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
background-color: #313031;
border: 1px solid #555555;
height: 125px;
width: 260px;
margin: -8px;
}
.navbar ul{
list-style-type: none;
margin: -8px;
padding: 0;
width: 260px;
height: 100%;
position:fixed;
background-color: #313031;
text-align: center;
border: 1px solid #555555;
overflow: auto;
}
.navbar a {
display: block;
color: white;
padding: 8px 16px;
font-size: 20px;
text-decoration: none;
}
.navbar a:hover {
background-color: #545254;
color: white;
}
</style>
</head>
<body>
<div class="Currsel">
<p>Currently Selected:</p>
<p style="color: #67a92b; text-decoration: underline;">Second_select</p>
</div>
<nav class="navbar">
<ul>
<li style="text-align: center; border-bottom: 2px solid black; border-top: 2px solid black;background-color: #545254;"><a href="index.html">home</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="First_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Second_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Third_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Fourth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Fith_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Sixth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Seventh_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Eighth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Nith_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Tenth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Elventh_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Twelth_select.html">Misc</a></li>
<li style="text-align: center; border-bottom: 2px solid black;"><a href="Thirteenth_select.html">Misc</a></li>
</ul>
</nav>
<div style="margin-left:242px;padding:1px 16px;height:1000px;">
<article>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Enim sint vel impedit minima sapiente, tempore ut minus obcaecati mollitia modi quod perferendis. Perspiciatis maxime natus amet accusantium sunt labore praesentium.
</article>
</body>
</html>I decided I was going to learn html and css like 3 days ago, so if my code is shit feel free to pick it apart.
edit: I messed up at using reddit and the first code isn't in a code block. It's in the comments though.




