Hi everyone please me i'm facing an issue in css I have created one table in html keeping table first row and first column fixed remaining table cell should scroll horizontal scroll bar For table first row and first column i have wrote style:"position:absolute" after that table first column going out of the table i cant able to give height and fit inside the tableI have sent image which i'm facing issue for that Please help me!
Asked
Active
Viewed 329 times
1
-
Please provide some code, preferably a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – kalsowerus Jul 06 '17 at 06:26
-
Provide a working example so we can rewrite it. – Berkay Yaylacı Jul 06 '17 at 06:48
-
I can see you want the first column to be fixed, but are you sure you want the first row fixed? That would mean that once you start scrolling, all the headers will be wrong... – JasperZelf Jul 06 '17 at 07:07
-
This might help: https://stackoverflow.com/questions/1312236/how-do-i-create-an-html-table-with-fixed-frozen-left-column-and-scrollable-body – JasperZelf Jul 06 '17 at 07:13
1 Answers
0
Try this code. (dont forget to include bootstrap files)
**HTML**
<div class="container">
<table class="table table-fixed">
<thead>
<tr>
<th class="col-xs-3">First Name</th>
<th class="col-xs-3">Last Name</th>
<th class="col-xs-6">E-mail</th>
</tr>
</thead>
<tbody>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
<tr>
<td class="col-xs-3">John</td>
<td class="col-xs-3">Doe</td>
<td class="col-xs-6">johndoe@email.com</td>
</tr>
</tbody>
</table>
</div>
**CSS**
body{
background-color: #bdc3c7;
}
.table-fixed{
width: 100%;
background-color: #f3f3f3;
tbody{
height:200px;
overflow-y:auto;
width: 100%;
}
thead,tbody,tr,td,th{
display:block;
}
tbody{
td{
float:left;
}
}
thead {
tr{
th{
float:left;
background-color: #f39c12;
border-color:#e67e22;
}
}
}
}

Raru
- 371
- 1
- 4
- 19