7
I need to fix the first line 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 lot of things, but I chose to take them out so they wouldn’t hurt the code.
I thought I’d just get the first one tr
in css and put position:fixed
.
And then another div wrapped around the others trs
, ie wrapped in php tags.
But the biggest problem is that the width of each cell of the table does not follow the width of the cells th
and then everything gets crooked because the width of the table gets smaller than the first line...
I want to do this with css (accepted solution with javascript in second case, but no jquery, please) Thanks!
Did you see this? http://answall.com/questions/32304/%C3%89-poss%C3%Advel-add-a-behavior-de-overflow-with-scroll-only-no-tbody-de
– bfavaretto
I don’t understand what the solution is?! It doesn’t work here. What happens is that when I put the first fixed line, the rest is compressed. And it’s no use to touch the rest via css. It doesn’t change anything in practice.
– HiHello
This table will occupy the entire page or it will be inside an element?
– Renan Gomes
Every page, Renan.
– HiHello