Table fixed header and scrollable body

前端 未结 29 1234
粉色の甜心
粉色の甜心 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 06:04

    Here is the working solution:

    table {
        width: 100%;
    }
    
    thead, tbody, tr, td, th { display: block; }
    
    tr:after {
        content: ' ';
        display: block;
        visibility: hidden;
        clear: both;
    }
    
    thead th {
        height: 30px;
    
        /*text-align: left;*/
    }
    
    tbody {
        height: 120px;
        overflow-y: auto;
    }
    
    thead {
        /* fallback */
    }
    
    
    tbody td, thead th {
        width: 19.2%;
        float: left;
    }
    
    
    
    Make Model Color Year
    Ford Escort Blue 2000
    Ford Escort Blue 2000
    Ford Escort Blue 2000
    Ford Escort Blue 2000

    Link to jsfiddle

提交回复
热议问题