← Back to CSS
75

Sidebar component: adaptive lateral navigation

Learn how to build clear, maintainable sidebars with a two-column layout, active states and sticky behavior so long-form content and documentation stay navigable without overwhelming the page.

📘 Theory

The base sidebar layout

Two columns: navigation and content.

1

Define a Grid container with one fixed column for navigation and one flexible column for the main content area.

2

On smaller screens, switch to a single-column layout so the sidebar does not consume too much horizontal space.

Sticky behavior plus the active state

Keep navigation visible while preserving reading context.

1

The sidebar can be pinned with `position: sticky` and a `top` value that respects the space already occupied by the header.

2

Highlight the active link with enough contrast so users can always tell where they are inside the content structure.

🧪 Learn by doing

Example Demo: course sidebar A lateral index with a clear active state and a stable content relationship.

🏁 Challenges

Challenge Challenge: sticky sidebar on desktop Configure `.sidebar` so it stays visible during scroll with `top: 1rem`.

🧰 Resources

Test

Check your knowledge with a test about CSS.

Test for CSS
CodePen: UI cards with hover and layout patterns
Open in CodePen

What is this?

I'm Cristian Eslava and I sometimes build websites so both you and I can learn and experiment. culTest

I made this in February 2026 to make learning easier for my students. The idea is to learn web development by practicing and to keep expanding the project with new topics, tests and challenges.

It draws inspiration from MDN, W3Schools, CodePen, Manz and many other web development references. I wanted to combine useful theory, runnable examples, challenges and the testing system I had already built for culTest. culTest

If you liked it, if you didn't, or if you want to get in touch, write to me at cristianeslava@gmail.com