Ich habe Scrollable tbody mit einem festen Header. Die Spalte wird nicht richtig ausgerichtet, auch nachdem die Breite in td angegeben wurde. Ich muss kein extra Div hinzufügen, um dasselbe zu erreichen.Scrollable tbody td Breite nicht vollen Platz nach der Bereitstellung Breite
table.tables {
width:590px;
position: relative;
height: 200px;
}
table.tables thead {
display: table;
}
table.tables tbody {
display: block;
}
table.tables thead {
position: relative;
width: 100%;
background: aqua;
}
.tables tbody {
height: 200px;
overflow-y: auto;
overflow-x: hidden;
}
table.tables tbody tr {
display:table;
table-layout: fixed;
width: 100%;
}
table.tables thead tr {
display:table;
table-layout: fixed;
width: 100%;
}
<div class="wrap">
<table class="tables">
<thead>
<tr>
<th width="40%">Header1</th>
<th width="40%">Header2</th>
<th width="20%">Header3</th>
</tr>
</thead>
<tbody>
<tr>
<td width="40%">Value1</td>
<td width="40%">Value2</td>
<td width="20%">Value3</td>
</tr>
<tr>
<td>Value1</td>
<td>Value2</td>
<td>Value2</td>
</tr>
<tr>
<td>Value1</td>
<td>Value2</td>
<td>Value2</td>
</tr>
<tr>
<td>Value1</td>
<td>Value2</td>
<td>Value2</td>
</tr>
<tr>
<td>Value1</td>
<td>Value2</td>
<td>Value2</td>
</tr>
<tr>
<td>Value1</td>
<td>Value2</td>
<td>Value2</td>
</tr>
<tr>
<td>Value1</td>
<td>Value2</td>
<td>Value2</td>
</tr>
<tr>
<td>Value1</td>
<td>Value2</td>
<td>Value2</td>
</tr>
<tr>
<td>Value1</td>
<td>Value2</td>
<td>Value2</td>
</tr>
<tr>
<td>Value1</td>
<td>Value2</td>
<td>Value2</td>
</tr>
<tr>
<td>Value1</td>
<td>Value2</td>
<td>Value2</td>
</tr>
<tr>
<td>Value1</td>
<td>Value2</td>
<td>Value2</td>
</tr>
<tr>
<td>Value1</td>
<td>Value2</td>
<td>Value2</td>
</tr>
<tr>
<td>Value1</td>
<td>Value2</td>
<td>Value2</td>
</tr>
</tbody>
</table>
</div>
Ich glaube nicht, dass es ein 'Breite' Problem gibt. Sowohl Header- als auch Body-Spalten haben jeweils die gleiche Breite, aber aufgrund von Unterschieden in der Ausrichtung scheinen sie ein wenig aus. – Narxx
@SanchitPatiyal Ich brauche Spalte der ersten Zeile und alle Zeile Spalte muss mit der Spalte address ausgerichtet werden. Kein Zentrum. –
@Narxx nein es ist nicht alligning –