我用HTML创建了一个表,我想显示它的标题是固定的(滚动只会影响到正文)。
我找到了一个解决方案,它几乎可以按我想要的方式工作。
tbody {
display:block;
height:500px;
overflow:auto;
}
thead, tbody tr {
display:table;
width:100%;
table-layout:fixed;/* even columns width , fix width of table too*/
}
thead {
width: calc( 100% - 1em )/* scrollbar is average 1em/16px width, remove it from thead width */
}
table {
width:400px;
}
问题是这个属性
table-layout: fixed
,它固定了列的宽度,因此没有正确显示我的列(它们重叠):
我怎么修?
我已经尝试了四个可能的值
table-layout