Table header to stay fixed at the top when user scrolls it out of view with jQuery

后端 未结 25 2554
悲&欢浪女
悲&欢浪女 2020-11-22 05:38

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

25条回答
  •  野性不改
    2020-11-22 06:19

    I found a simple jQuery library called Sticky Table Headers. Two lines of code and it did exactly what I wanted. The solutions above don't manage the column widths, so if you have table cells that take up a lot of space, the resulting size of the persistent header will not match your table's width.

    http://plugins.jquery.com/StickyTableHeaders/

    Usage info here: https://github.com/jmosbech/StickyTableHeaders

提交回复
热议问题