i want a sticky side nav. I have three sections and place the nev in my first section but it just sticks till the end of the first section.
HTML:
<body>
<div id="sections">
<div class="section" id="section1">
<nav id="my-navigation">
<div id="container">
<li><a href="">Start.</a></li>
<li><a href="">My work.</a></li>
<li><a href="">Skills.</a></li>
<li><a href="">Education.</a></li>
</div>
</nav>
</div>
<div class="section" id="section2"></div>
<div class="section" id="section3"></div>
</div>
</body>
CSS:
* {
font-size: 16px;
margin: 0;
}
.section{
width: 100%;
height: 100vh;
}
#section1 {
background-color: grey;
}
#section2 {
background-color: aquamarine;
}
#section3 {
background-color: brown;
}
#my-navigation {
display: inline-block;
position: sticky;
height: 75vh;
top: calc(25vh/2);
left: 30px;
border-left: 2px solid #000;
}
#container {
display: flex;
height: inherit;
flex-direction: column;
justify-content: space-around;
}
#container > li {
list-style: none;
margin-left: 1rem;
}
I already tried to place the nav before the first section like this:
<body>
<div id="sections">
<nav id="my-navigation">
<div id="container">
<li><a href="">Start.</a></li>
<li><a href="">My work.</a></li>
<li><a href="">Skills.</a></li>
<li><a href="">Education.</a></li>
</div>
</nav>
<div class="section" id="section1"></div>
<div class="section" id="section2"></div>
<div class="section" id="section3"></div>
</div>
</body>
But the result was not what i expected.
Is there a possibility to place the nav somehow independent? It just should be sticky for the whole website.