I have a large table that goes beyond the height of the viewport. This table is scrollable horizontally, hence the horizontal scrollbar at the bottom of the table. But the scrollbar is not visible unless a users scrolls the whole page down. I need that scrollbar to be visible always.
I tried setting position: sticky
to the ::-webkit-scrollbar
pseudo-element of the horizontally scrollable element and some value of top:
but my browser (Chrome) doesn't seem to see this. Probably, because the position
of the horizontally scrollable element itself is not sticky
and the browser wants the positions to match:
I also tried setting something like transform: translateY(50px);
but it doesn't work as well. The browser just ignores it.
I guess I could create some element using js that would listen to the scroll event of the table and render a custom scrollbar that I would be able to position wherever I want. But it seems to be too much, and I also want scrollbar to be native looking (matching different styles on different platforms)
Is there any workaround, maybe using some fake scrollbar made with ::before
that scrolls with other elements?
EDIT: Here's a codesandbox link that shows the problem https://codesandbox.io/s/frosty-hamilton-2pm610?file=/index.html