我正在用 HTML5 和 CSS 制作表格。当我尝试添加滚动条时,表头和正文之间出现了一个巨大的间隙。这是我的代码:
http://jsfiddle.net/AaronJohnson/u23g9/
HTML5 代码:
<table id="mytable">
<tr>
<th> <span>
Playlist
</span>
</th>
</tr>
<tbody>
<tr>
<td> <span>
LINK 1
</span>
</td>
</tr>
<tr>
<td> <span>
LINK 2
</span>
</td>
</tr>
<tr>
<td> <span>
LINK 3
</span>
</td>
</tr>
<tr>
<td> <span>
LINK 4
</span>
</td>
</tr>
<tr>
<td> <span>
LINK 5
</span>
</td>
</tr>
<tr>
<td> <span>
LINK 6
</span>
</td>
</tr>
<tr>
<td> <span>
LINK 7
</span>
</td>
</tr>
</tbody>
</table>
CSS 代码:
table#mytable {
width:100%;
border-collapse:separate;
background:crimson;
border-radius: 15px;
}
tbody {
overflow: auto;
height: 100px;
float: left;
width: 100%;
}
td {
text-align:center;
background:gray;
border-bottom:5px solid black;
border-radius: 15px;
}
th {
font-weight:bold;
text-align:center;
background:crimson;
border-bottom:5px solid black;
border-top-left-radius: 15px;
border-top-right-radius: 15px;
float: left;
width: 100%;
}
tr {
width: 100%;
display: table;
}