DEV Community

Discussion on: So hard to make table header sticky

Collapse
 
ankit_goyal_7c0cd4d12fc59 profile image
Ankit Goyal

Hi Jennie, thank you for the incredible post! I've looked everywhere to get sticky headers working and your code WORKED!

Quick question, my table needs to scroll horizontally as well but the sticky headers don't scroll horizontally when I scroll my content horizontally. What do you recommend I do?

Collapse
 
jennieji profile image
Jennie

Hi Ankit, I just see your message. And the post is a bit out-dated! Try this awesome easy approach for the modern browsers instead: css-tricks.com/making-tables-with-...

Scrolling horizontally at the same time would be tricky with my hacky approach as the header and table no longer syncs position.

While we can make the vertical "sticky" scrolling look more natural by applying simple animation on the header, horizontal scroll will not be that straight forward as I can imagine. In this case I will consider to use a special controlled scroll component which allows me to know control the scroll speed animation and apply the same animation to the header. Honestly it's not worth to add such heavy things.