How to create a sidebar that’s sticky but also scrolls
By Flavio Copes
Learn how to build a sidebar that stays sticky yet scrolls on short screens using CSS position sticky, top 0, height 100vh, and overflow-y auto, or Tailwind.
~~~
To make a sidebar fixed but also accommodate screens that are not tall enough to contain the entire sidebar, use this CSS:
.sidebar {
position: sticky;
top: 0;
height: 100vh;
overflow-y: auto;
}
Using Tailwind CSS:
<div class='sticky top-0 h-screen overflow-y-auto'>
...
</div>~~~
Related posts about css: