I have looked around the internet for help with this issue; often even encountering solutions for other problems, but I still cannot achieve what I am looking for. I want a sticky side-bar that will stay with the main content of my page. Later, I will add functionality to that sidebar to enable it to link to various parts of the content (like a table of contents).
.content-container {
display: flex
}
.sticky {
position: sticky;
top: 0
}
.main {
flex-grow: 1
}
<div class="content-container"> .
<div class="sticky">
<div> Section Header 1</div>
<div> Section Header 2 </div>
<div> Section Header 3 </div>
<div> Section Header 4 </div>
</div>
<div class="main">
<div> Test </div>
<div> Test </div>
<div> Test </div>
<div> Test </div>
<div> Test </div>
<div> Test </div>
<div> Test </div>
<div> Test </div>
<div> Test </div>
<div> Test </div>
<div> Test </div>
</div>
</div>
As of right now, the flex containers are doing their job nicely (putting the two divs side by side), but the sticky section is not working like a sticky element, because it's inside a flex-box. Any help would be greatly appreciated.