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
Mannix4mo 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
Bismuth4mo 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
MarkBoots4mo ago
it is because you set the height of '#root' to a fixed 100%, make it a min-height
MarkBoots
MarkBoots4mo 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
Bismuth4mo ago
is there a way i can keep that scroll bar on right side instead of in middle content just like in facebook ?
MarkBoots
MarkBoots4mo ago
no, in that case you do need your approach
Bismuth
Bismuth4mo ago
No description
Bismuth
Bismuth4mo ago
which one position sticky ?
MarkBoots
MarkBoots4mo 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
Bismuth4mo ago
making fixed will not take the space and all content are scattered
MarkBoots
MarkBoots4mo ago
You can make them sticky but then you'll need some calculations (js) to determine the top position
MarkBoots
MarkBoots4mo ago
this you can do with a couple of js lines https://codepen.io/MarkBoots/pen/qBvwoVd?editors=1111