Fixing table header and making the table body scroll in React

13.1k Views Asked by At

Here is a code sandbox URL, which contains React code for a table component,

I want to make the header in this component fixed at the top and the table body to be scrollable. For that, I found an answer here. But if I make tbody as display: block and thead as display: table and do the changes as suggested in the above answer, then my table header columns won't align with my tbody columns, as attached in the screenshot here.

Table header columns aren't aligned with Table body columns

I want to make the header fixed at the top while the content of body should be scrollable and alignment shouldn't be disturbed. How can I achieve it? Can someone please help. Thanks a lot in advance.

0

There are 0 best solutions below