How to stick table header(thead) on top while scrolling down the table rows with fixed header(navbar) in bootstrap 3?

后端 未结 10 2123
隐瞒了意图╮
隐瞒了意图╮ 2020-11-28 03:04

Bootstrap layout with fixed-navbar. Having table with so many rows in body.

Issue? As i scroll the page navigation-bar will be there be

10条回答
  •  南笙
    南笙 (楼主)
    2020-11-28 03:50

    For anyone looking for this functionality in 2018, it's much cleaner to do this with just CSS using position: sticky.

    position: sticky doesn't work with some table elements (thead/tr) in Chrome. You can move sticky to tds/ths of tr you need to be sticky. Like this:

    thead tr:nth-child(1) th {
      background: white;
      position: sticky;
      top: 0;
      z-index: 10;
    }
    

提交回复
热议问题