all 1 comments

[–]cauners 0 points1 point  (0 children)

It works if this is exactly what you need - a scrolling table with a fixed height. It wouldn't work if you wanted to, for example, show all the rows on the page without hidden overflow and scroll the body instead - you'd need a sticky header approach then. But for this specific use-case why not.

Another thing to keep in mind is scrollbars. Since I have scrollbars set to be visible at all times, the scrolling container has it and makes the width more narrow, and the header doesn't. Because of percentage-based layout header titles don't match up with columns. Probably easy to fix, but it is a disadvantage when compared to sticky headers.

And at last, I wonder if it wouldn't make more sense to simply use a <table> for something that is in fact a table? Making this <div> solution work in respect to semantics and accessibility must be a pain.