I am looking for a way to scroll the contents of my table horizontally while keeping the table structure fixed. Currently, when I try to scroll, the table structure scrolls along with the content, resulting in visibility issues at both ends due to the corner radius. I want the background structure to remain fixed while only the content scrolls horizontally. The desired output can be seen in the image linked below.
https://i.sstatic.net/OoW70.jpg
table {
width: 120%;
}
td {
padding-top: 15px;
padding-bottom: 15px;
border-bottom: 1px solid #f5f5f5;
padding-left: 20px;
}
.scrollsec {
overflow-x: scroll;
}
th {
padding-top: 15px;
padding-bottom: 15px;
padding-left: 20px;
}
th:nth-child(1) {
border-radius: 11px 0px 0px 9px;
}
th:nth-last-child(1) {
border-radius: 0px 11px 9px 0px;
}
.bodySec {
background: #fff;
border-radius: 10px;
}
.he20 {
height: 20px;
}
.bodySec tr:nth-child(1) td:nth-child(1) {
border-radius: 11px 0px 0px 0px;
}
.bodySec tr:nth-child(1) td:nth-last-child(1) {
border-radius: 0px 9px 0px 0px;
}
.bodySec tr:nth-last-child(1) td:nth-last-child(1) {
border-radius: 0px 0px 11px 0px;
}
.bodySec tr:nth-last-child(1) td:nth-child(1) {
border-radius: 0px 0px 0px 11px;
}
.scrollsec::-webkit-scrollbar-thumb {
height: 10px;
border-radius: 10px;
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5);
}
<div class="col-md-12 col-sm-12 col-xs-12 scrollsec">
<table>
<thead class='tableHeadSec'>
<tr>
<th>Transaction Id</th>
<th>Transaction Id</th>
<th>Transaction Id</th>
<th>Transaction Id</th>
<th>Transaction Id</th>
<th>Transaction Id</th>
<th>Transaction Id</th>
</tr>
</thead>
<tr class='he20'></tr>
<tbody class='bodySec'>
<tr>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
</tr>
<tr>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
</tr>
<tr>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
</tr>
<tr>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
</tr>
<tr>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
<td>Transaction Id</td>
</tr>
</tbody>
</table>
</div>