In my web layout, I have a left-sided sideNav
div and a right-sided main
div set up as follows:
#sideNav {
background-color: #012d20;
position: fixed;
z-index: 1;
top: 0;
left: 0;
overflow: hidden;
border-right-style: groove;
height: 100vh;
}
<div class="row">
<!-- navigation sidebar -->
<div class="col-2 pt-5" id="sideNav">
...
</div>
<!-- main content area -->
<main class="col-10">
...
</main>
</div>
Although the code functions correctly, I am encountering an issue where the left portion of main
is positioned behind sideNav
. Removing the position
property from the sideNav
CSS resolves this problem, but then sideNav
loses its fixed positioning and scrolls with the page.
How can I maintain the fixed positioning of sideNav
while ensuring that my divs are displayed properly?