I've tried every possible solution to get this to work, but nothing seems to be working.
I have this webpage I've created, and I have a table shown here, and I want to have my header fixed. That part I have mastered, but the thead columns dont align to the tbody columns.
I have tried assigning width to my td's manually, that didn't work either.
This is my code so far:
.tableSqlContent {
table-layout: fixed;
border-collapse: collapse;
}
.tableSqlContent th, td {
padding: 7px;
text-align: left;
}
.tableSqlContent thead {
background-color: #003265;
color: white;
font-weight: bold;
cursor: default;
}
.tableSqlContent thead tr {
display:inline-block;
position: relative;
height: 37px;
}
.tableSqlContent tbody tr td:nth-child(1) {min-width: 33%;}
.tableSqlContent tbody tr td:nth-child(2) {min-width: 20%;}
.tableSqlContent tbody tr td:nth-child(3) {min-width: 20%;}
.tableSqlContent tbody tr td:nth-child(4) {min-width: 10%;}
.tableSqlContent tbody tr td:nth-child(5) {min-width: 10%;}
.tableSqlContent tbody tr td:nth-child(6) {min-width: 7%;}
.tableSqlContent thead tr th:nth-child(1) {min-width: 33%;}
.tableSqlContent thead tr th:nth-child(2) {min-width: 20%;}
.tableSqlContent thead tr th:nth-child(3) {min-width: 20%;}
.tableSqlContent thead tr th:nth-child(4) {min-width: 10%;}
.tableSqlContent thead tr th:nth-child(5) {min-width: 10%;}
.tableSqlContent thead tr th:nth-child(6) {min-width: 7%;}
.tableSqlContent tbody {
display: block;
height: 700px;
overflow: auto;
}
.tableSqlContent tbody tr:nth-child(even) {
background-color: #eeeeee;
}
.tableSqlContent tbody tr:hover {
color: #003265;
cursor: pointer;
background-color: #dddddd;
}
<table Class="tableSqlContent">
<thead>
<tr>
<th>Connectionstring</th>
<th>Klinik Navn</th>
<th>IP_Adresse</th>
<th>P-nummer</th>
<th>Systemtype</th>
<th>Version</th>
</tr>
</thead>
<tbody>
<?php
foreach($dbh->query($query) as $rows){
?>
<tr>
<td><?php echo $rows['ConnectionString']?></td>
<td><?php echo $rows['Name']?></td>
<td><?php echo $rows['IP_Adresse']?></td>
<td><?php echo $rows['Ydernummer']?></td>
<td><?php echo $rows['Systemtype']?></td>
<td><?php echo $rows['Version']?></td>
</tr>
<?php
}
?>
</tbody>
</table>