能告诉我如何实现表格的标头。它位于div中,并带有溢出:自动并向右滚动。而且我支持IE10 +。
这是我的html
<div class='table-block'>
<div class='table-header'>
<div>
header 1
</div>
<div>
header 1
</div>
<div>
header 1
</div>
<div>
header 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
<div class='table-body'>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
<div>
body 1
</div>
</div>
</div>
这是我的CSS
.table-block{
overflow: auto;
}
.table-header{
display: table;
table-layout: fixed;
width: 100%;
}
.table-header > div{
display: table-cell;
border: 1px solid;
width: 1000px;
}
.table-body{
display: table;
table-layout: fixed;
width: 100%;
}
.table-body > div{
display: table-cell;
border: 1px solid;
width: 1000px;
}
我需要完全相同的标记。
请有人给我一个建议。
这里的提琴制作得很少,请检查一下https://jsfiddle.net/kzmwtuhb/2/
答案 0 :(得分:0)
我已经更新了您的jsfiddle。我不确定我的解决方案是您要寻找的。 p>