How to make this layout ?

https://codepen.io/web-test-the-sasster/pen/zYbXPPg bascially i want to fix right/left sidebar fix and nav to be sticky and main content to scroll. How can i acheive such layout ?
web test
CodePen
zYbXPPg
...
13 Replies
Mannix
Mannix10mo ago
you have two options first you set align-items: start; on the .container and
position: sticky;
top:0;
position: sticky;
top:0;
on both sidebars or
position:sticky;
top:0;
align-self: start;
position:sticky;
top:0;
align-self: start;
on both sidebars
Bismuth
BismuthOP10mo ago
I want navbar to be sticky but not sidebar sidebar will be there as it is and main content to be scrollable i made a few changes here but i don't know why navbar is not sticking here when i reach to post 18
MarkBoots
MarkBoots10mo ago
it is because you set the height of '#root' to a fixed 100%, make it a min-height
MarkBoots
MarkBoots10mo ago
you can also use grid to setup the layout over the total height of the screen and give main an overflow: auto so it is able to scroll. that way you don't need a sticky at all https://codepen.io/MarkBoots/pen/PoLgQrG
Bismuth
BismuthOP10mo ago
is there a way i can keep that scroll bar on right side instead of in middle content just like in facebook ?
MarkBoots
MarkBoots10mo ago
no, in that case you do need your approach
Bismuth
BismuthOP10mo ago
No description
Bismuth
BismuthOP10mo ago
which one position sticky ?
MarkBoots
MarkBoots10mo ago
nav is sticky, side bars are fixed indeed. or also possibly sticky but you need some calculations (js) to determine the top position
Bismuth
BismuthOP10mo ago
making fixed will not take the space and all content are scattered
MarkBoots
MarkBoots10mo ago
You can make them sticky but then you'll need some calculations (js) to determine the top position
Bismuth
BismuthOP10mo ago
MarkBoots
MarkBoots10mo ago
this you can do with a couple of js lines https://codepen.io/MarkBoots/pen/qBvwoVd?editors=1111
Want results from more Discord servers?
Add your server