ag_dhruv ag_dhruv - 6 months ago 14
HTML Question

Why is the HTML table column width less that what is required?

I am using PHP

to dynamically enter an change entries to an HTML table. But when I open the page containing the table, it sometimes loads perfectly, and other times it is rendered in a peculiar manner. What could be the problem here?

The problem with the table

Edit : here's my code.


<div class="my-table-container">
<th>School Code</th>
<th>Time Completed</th>
$rank = 1;
echo "<tr>";
echo "<td>".$rank."</td>";
echo "<td>".$arr[$x]['scl_name']."</td>";
echo "<td>".$arr[$x]['lvl']."</td>";
echo "<td>".$arr[$x]['tlc']."</td>";
echo "</tr>";


background : #eaf7ee;
border : 1px solid #c6d9ce;
padding : 3%;
padding-bottom : 2%;
margin : 0px auto;
flex-basis : 50%;
text-align : center;
margin-top: 4%;
margin-bottom: 4%;

.my-table-container table{
background-color: white;
margin: 0px auto;
border-collapse: collapse;

border : 1px solid black;

padding: 4%;
font-size: 20px;
font-family: 'Lato', sans-serif;
text-align: center;
vertical-align: middle;



white-space: nowrap;

either to the entire thing, or just the first row so that the headings don't get squished.

Also instead of % for padding, put a fixed number like 4px