Skip to content

How to create a sidebar that’s sticky but also scrolls

New Courses Coming Soon

Join the waiting lists

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'>
→ Get my CSS Handbook
→ Read my CSS Tutorial on The Valley of Code

Here is how can I help you: