我想要一個固定標題的tbody內的垂直滾動條。我嘗試了鏈接中提供的解決方案。垂直滾動內部tbody的HTML表格
HTML table with 100% width, with vertical scroll inside tbody
table {
width: 100%;
border-spacing: 0;
}
thead, tbody, tr, th, td { display: block; }
thead tr {
/* fallback */
width: 97%;
/* minus scroll bar width */
width: -webkit-calc(100% - 16px);
width: -moz-calc(100% - 16px);
width: calc(100% - 16px);
}
tr:after { /* clearing float */
content: ' ';
display: block;
visibility: hidden;
clear: both;
}
tbody {
height: 100px;
overflow-y: auto;
overflow-x: hidden;
}
tbody td, thead th {
width: 19%; /* 19% is less than (100%/5 cols) = 20% */
float: left;
}
如果滾動條appears.But如果行很少,滾動欄沒有顯示它工作正常,那麼THEAD沒有與TBODY對齊。我怎樣才能解決這個問題與CSS?
可以插入在後一個的jsfiddle? –