css-tables-demo icon indicating copy to clipboard operation
css-tables-demo copied to clipboard

Thank you! 🙂

Open Eli-Black-Work opened this issue 2 years ago • 1 comments

Just wanted to say thank you so much for this code snippet! 🙂

After spending two days trying to figure out how to have a table that scrolls horizontally with a table body that scrolls vertically, I finally found your article on this! 🙂 (https://joshondesign.com/2015/05/23/csstable)

For me, the magic piece was putting width: fit-content on the <tbody>.

By the way, for anyone else who runs across this repo, there are two changes to the code that you probably want to make:

  • For overflow, use auto instead of scroll, so that the scrollbars are only shown when needed.
  • Use width: fit-content instead of width: -webkit-fit-content

Thank you again!! 🙂

Eli-Black-Work avatar Mar 15 '22 07:03 Eli-Black-Work

I'm glad this helped you. This method is 7 years old, however, so there's probably better ways to do it now using position:sticky.

joshmarinacci avatar Mar 15 '22 17:03 joshmarinacci