I would like to create an HTML table, where
- the table content is scrollable in x and y direction
- the first row is positioned sticky to the top
- the first column is positioned sticky to the left
- and all cells may have different heights based on their contents
Example
There are many examples online, that satisfy some of the requirements above but non of them satisfy the last requirement.
My Approach
1. Scrolling container
I used overflow: scroll
and fixed dimensions to create a scrollable container
2. & 3. Syncing cell heights
I tried to use the flex table from css tricks to sync the height of the cells.
2. Fixing cells
In addition to that I fixed the cells with css transforms.
On every scroll event I reposition the every fixed cell based on the scroll position.
That approach is obviously pretty laggy.
I didn't use position: fixed;
, because this would break out the cells from the overflow area.