我的笔:
http://codepen.io/helloworld/pen/qHDFB
我想创建一个html表:
我只想使用CSS。
它应该适用于IE10 +和最新的FF / Chrome。
您还可以使用Microsoft的新CSS Grid Layout,它将移植到webkit等...使用-ms-grid等...
如何使上面的单个样本工作,标题保持固定,并且表的主体有垂直滚动条而不是html主体本身?
HTML
<table>
<thead>
<tr>
<th>
<div>First</div>
</th>
<th>
<div>Second</div>
</th>
<th>
<div>Third</div>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
</tbody>
</table>
CSS
body, html{
margin:0;
padding:0;
height:100%;
width:100%;
}
table{
width:100%;
height:100%;
}
td{
width:33%;
border:black solid 1px;
}
tbody{
overflow-x:hidden;
overflow-y:auto;
}
tr td{
text-align:center;
height:100px;
}
th{
background:lightgray;
padding:10px;
border:black solid 1px;
}
答案 0 :(得分:5)
这不是你要找的吗? - http://www.imaputz.com/cssStuff/bigFourVersion.html
只需查看示例的来源,这应该让你前进。
答案 1 :(得分:-1)
<table>
<thead>
<tr>
<th>
<div>First</div>
</th>
<th>
<div>Second</div>
</th>
<th>
<div>Third</div>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
</tbody>
</table>