My goal is to set up a layout with a sticky header and left sidebar, and non-sticky DashboardBody
(the green-bordered box) that can be scrolled through (in which case the content at the top disappears "under" the sticky header). I'm using styled-components, and the two boxes under the header are wrapped in a BelowNavContainer
that is using flexbox.
The component ProjectContainer
encloses the entire view (including the header and sidebar as well). Since I only want a scrollbar on the DashboardBody
part, I set overflow: auto
for that and overflow: hidden
for ProjectContainer
. However this results in the user being unable to see the bottom of DashboardBody
- the bottom of the scrollbar (with the downward pointing arrow) is not visible either.
If I set overflow: auto
for ProjectContainer
then an additional scrollbar is added, and I can scroll to the bottom of DashboardBody
using these 2 scrollbars. But obviously, I only want one scrollbar.
What am I doing wrong and how can I fix this?
I've looked at related "overflow not working" questions. Their solutions did not work as I already do have a height
value specified.
Working demo: https://codesandbox.io/s/overflow-woes-i4dww
Note: it seems like CodeSandbox itself adds a scrollbar to the view, so I think the outermost one can be ignored. With webpack-dev-server (from create-react-app) on my own machine, I have one fewer scrollbar than what CodeSandbox shows.
I expect DashboardBody
to have a scrollbar that lets me scroll to the bottom of the div. I only want this component to have a scrollbar, i.e. the scrollbar should not start at the top of the screen alongside the header.
Currently, I can't seem to reach the bottom of its scrollbar without adding another scrollbar to its enclosing div, ProjectContainer
.