One solution could be to remove the CSS property position: fixed
from the <nav>
element. By doing this, the <nav>
element will be part of the page layout flow and won't cover the scrollbar of the <main>
.
However, removing the fixed position of the <nav>
may cause the bottom of the <main>
to overflow the screen due to the height of the <nav>
. To maintain the previous behavior, you can implement a vertical flex layout on the <body>
element so that the <main>
dynamically adjusts its size based on the remaining space available.
<html lang="en">
<script src="https://cdn.tailwindcss.com/3.4.0"></script>
<body class="flex flex-col h-screen">
<nav
class="flex flex-no-wrap items-center justify-between px-10 py-2 bg-slate-500"
>
<div>
<p>logo</p>
</div>
<div class="flex flex-row gap-10">
<ul class="flex flex-row items-center gap-5">
<li>
<a href="/">Home</a>
</li>
<li>
<a href="/about">About</a>
</li>
<li>
<a href="/about">Profile</a>
</li>
</ul>
<div
class="w-10 h-10 rounded-full flex items-center justify-center overflow-hidden"
>
<img
src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?q=80&w=1974&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
alt="profile"
width="40"
height="40"
/>
</div>
</div>
</nav>
<main class="snap-y snap-mandatory overflow-y-scroll grow">
<div class="flex flex-1 h-full w-full bg-black snap-start">
<p>page 1</p>
</div>
<div class="flex flex-1 h-full w-full bg-slate-500 snap-start">
<p>page 2</p>
</div>
<div class="flex flex-1 h-full w-full bg-amber-300 snap-start">
<p>page 3</p>
</div>
</main>
</body>
</html>