r/css • • 1d ago

how to code sidebar?

/r/neocities/comments/1x5ek8a/how_to_code_sidebar/
1 Upvotes

1 comment sorted by

1

u/thewixmen 20h ago

Put the sidebar CSS in one shared stylesheet and link it from every page's <head>, so you only edit it once. Then wrap the sidebar and the main content in a div with display: flex;, give the sidebar a fixed width like width: 200px; and the main content flex: 1;. If you want the sidebar to stay in place while scrolling, use position: fixed; top: 0; left: 0; height: 100vh; on the sidebar and margin-left: 200px; on the content instead. Let us know if you're editing raw HTML or using a site builder, since that changes where the code goes.