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
Mannix11mo 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
BismuthOP11mo 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
MarkBoots11mo ago
it is because you set the height of '#root' to a fixed 100%, make it a min-height
MarkBoots
MarkBoots11mo 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
BismuthOP11mo ago
is there a way i can keep that scroll bar on right side instead of in middle content just like in facebook ?
MarkBoots
MarkBoots11mo ago
no, in that case you do need your approach
Bismuth
BismuthOP11mo ago
No description
Bismuth
BismuthOP11mo ago
which one position sticky ?
MarkBoots
MarkBoots11mo 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
BismuthOP11mo ago
making fixed will not take the space and all content are scattered
MarkBoots
MarkBoots11mo ago
You can make them sticky but then you'll need some calculations (js) to determine the top position
Bismuth
BismuthOP11mo ago
MarkBoots
MarkBoots11mo 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