Skip to content

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

FULL-STACK WEB DEVELOPMENT BOOTCAMP

2024 COHORT SIGNUPS END TOMORROW

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>
→ Get my CSS Handbook
→ Read my CSS Tutorial
  • Learn modern web development in my BOOTCAMP (SIGNUP END TOMORROW FEB 20, 2024)
  • THE VALLEY OF CODE (+ PRO), your web development manual
  • I wrote 15+ coding BOOKS, all available in THE VALLEY OF CODE PRO
  • Indie solopreneur internet business masterclass SOLO LAB (summer 2024)