I need to set the first row of my table always at the top of the page. I have read several questions about this same problem, but I could not solve ...
My code:
<table border="2px">
<tr bgcolor="0099FF" id="topo">
<th> ID </th>
<th> Acertos Humanas </th>
<th> Nota humanas </th>
<th> Acertos Naturezas </th>
<th> Nota Naturezas </th>
<th> Acertos Linguagens </th>
<th> Nota Linguagens </th>
<th> Acertos Matematica </th>
<th> Nota Matematica </th>
<th> Soma acertos </th>
<th> Soma notas </th>
<th> Soma acertos(2) </th>
<th> Redacao </th>
<th> Media sem redacao </th>
<th> Media com redacao </th>
</tr>
<?php
$tudo = file('notas.txt');
for ($l=0; $l<90; $l++) {
$cada_item[$l] = explode (" ", $tudo[$l]);
$idd = $l+1;
$cor = $l%2 !=0 ? "#D0D0D0" : "white";
echo '<tr bgcolor="'.$cor.'"><td>'. $idd ."</td>";
for ($i=0; $i<14; $i++) {
echo "<td>". $cada_item[$l][$i] ."</td>";
}
echo "</tr>";
}
?>
</table>
I tried a number of things, but I preferred to take it to avoid harming the code.
I figured I'd just get the first tr
in css and put position:fixed
.
And then another div surrounded by the other trs
, that is, surrounded by php tags.
But the biggest problem is that the width of each cell in the table does not follow the width of cells th
and there everything is crooked because the width of the table is smaller than the width of the first row ...
I want to do this with css (I accept solution with javascript in the second case, but without jquery, please) Thanks!