From dc6db80fa72286704849ef61ee0e5ccb5841cb09 Mon Sep 17 00:00:00 2001 From: Bradley Taunt Date: Tue, 2 Jul 2024 14:28:49 -0400 Subject: Conversion to barf for testing purposes --- posts/Please_Make_Your_Table_Headings_Sticky.md | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 posts/Please_Make_Your_Table_Headings_Sticky.md (limited to 'posts/Please_Make_Your_Table_Headings_Sticky.md') diff --git a/posts/Please_Make_Your_Table_Headings_Sticky.md b/posts/Please_Make_Your_Table_Headings_Sticky.md new file mode 100644 index 0000000..249066a --- /dev/null +++ b/posts/Please_Make_Your_Table_Headings_Sticky.md @@ -0,0 +1,28 @@ +# Please Make Your Table Headings Sticky + +2024-02-23 + +I often stumble upon large data sets or table layouts across the web. When these tables contain hundreds of rows of content, things become problematic once you start to scroll... + +[Click here to see standard table headers video](/public/videos/not-fixed-header-tables.mp4) + +

This should be a header

+ +Look at that table header disappear! Now, if I scroll all the way down to item #300 (for example) will I remember what each column's data is associated with? If this is my first time looking at this table - probably not. Luckily we can fix this (no pun intended!) with a tiny amount of CSS. + +## Sticky Header + +Check it out: + +[Click here to see "fixed" table headers video](/public/videos/fixed-header-tables.mp4) + +Pretty awesome, right? It might look like magic but it's actually very easy to implement. You only need to add 2 CSS properties on your `thead`: + + position: sticky; + top: 0; + +That's it! Best of all, `sticky` has [~96% global support](https://caniuse.com/?search=sticky) which means this isn't some "bleeding-edge" property and can safely support a ton of browsers. Not to mention the improved experience for your end-users! + +You can view a live demo of this table on the [CodePen example pen](https://codepen.io/bradleytaunt/pen/bGZyJBj). + +If you found this interesting, feel free to check out my other table-focused post: [Making Tables Responsive With Minimal CSS](/posts/tables/) -- cgit v1.2.3-54-g00ecf