I want to have a fixed table header. If the table is scrolled the table header stays on top. Unfortunately it loses its width information. how can i improve the table?
HTML
<div class="wrap">
<table>
<tbody>
<tr>
<td>From</td>
<td>Subject</td>
<td>Date</td>
</tr>
<tr>
<td>Peter Pan</td>
<td>Apple</td>
<td>30.06.2014</td>
</tr>
<tr>
<td>Lisa Lama</td>
<td>Banana</td>
<td>10.03.2013</td>
</tr>
<tr>
<td>Steven</td>
<td>Tuba</td>
<td>12.01.2013</td>
</tr>
</tbody>
</table>
CSS
.wrap{
border: 4px solid lightgrey;
height: 100px;
width: 470px;
overflow: auto;
}
table{
width: 400px;
}
table tr:first-child{
background: lightgrey;
border: 1px solid;
position: fixed;
}
td{
padding: 20px;
}