Table fixed header and scrollable body

前端 未结 29 1263
粉色の甜心
粉色の甜心 2020-11-22 05:33

I am trying to make a table with fixed header and a scrollable content using the bootstrap 3 table. Unfortunately the solutions I have found does not work with bootstrap or

29条回答
  •  无人及你
    2020-11-22 05:43

    First add some markup for a bootstrap table. Here I created a striped table but also have added a custom table class .table-scroll which adds vertical scroll bar to the table and makes the table header fixed while scrolling down.

    # First Name Last Name County
    1 Andrew Jackson Washington
    2 Thomas Marion Jackson
    3 Benjamin Warren Lincoln
    4 Grant Wayne Union
    5 John Adams Marshall
    6 Morgan Lee Lake
    7 John Henry Brown
    8 William Jacob Orange
    9 Kelly Davidson Taylor
    10 Colleen Hurst Randolph
    11 Rhona Herrod Cumberland
    12 Jane Paul Marshall
    13 Ashton Fox Calhoun
    14 Garrett John Madison
    15 Fredie Winters Washington

    css

    .table-scroll tbody {
        position: absolute;
        overflow-y: scroll;
        height: 250px;
    }
    
    .table-scroll tr {
        width: 100%;
        table-layout: fixed;
        display: inline-table;
    }
    
    .table-scroll thead > tr > th {
        border: none;
    }
    

提交回复
热议问题