I am trying to design an HTML table where the header will stay at the top of the page when AND ONLY when the user scrolls it out of view. For example, the table may be 500
A bit late to the party, but here is an implementation that works with multiple tables on the same page and "jank" free (using requestAnimationFrame). Also there's no need to provide any width on the columns. Horizontal scrolling works as well.
The headers are defined in a div
so you are free to add any markup there (like buttons), if required. This is all the HTML that is needed:
col 1
col 2
col 3
https://jsfiddle.net/lloydleo/bk5pt5gs/