JSFiddle - React, Tailwind, and code Playground
by ppgab
HTML
I want to be able to scroll only the table while mantaining 100% width/height on the table and resizable on the parent
<hr>
<div class="floating-middle">
<div class="sticky sticky-top">
I'm a sticky header
</div>
<div class="table-wrapper">
<table>
<thead>
<th>Column1</th>
<th>Column2</th>
<th>Column3</th>
<th>Column4</th>
<th>Column5</th>
</thead>
<tbody>
<tr>
<td>Datum1</td>
<td>Datum2</td>
<td>Datum3</td>
<td>Datum4</td>
<td>Datum5</td>
</tr>
<tr>
<td>Datum1</td>
<td>Datum2</td>
<td>Datum3</td>
<td>Datum4</td>
<td>Datum5</td>
</tr>
<tr>
<td>Datum1</td>
<td>Datum2</td>
<td>Datum3</td>
<td>Datum4</td>
<td>Datum5</td>
</tr>
<tr>
<td>Datum1</td>
<td>Datum2</td>
<td>Datum3</td>
<td>Datum4</td>
<td>Datum5</td>
</tr>
<tr>
<td>Datum1</td>
<td>Datum2</td>
<td>Datum3</td>
<td>Datum4</td>
<td>Datum5</td>
</tr>
<tr>
<td>Datum1</td>
<td>Datum2</td>
<td>Datum3</td>
<td>Datum4</td>
<td>Datum5</td>
</tr>
<tr>
<td>Datum1</td>
<td>Datum2</td>
<td>Datum3</td>
<td>Datum4</td>
<td>Datum5</td>
</tr>
<tr>
<td>Datum1</td>
<td>Datum2</td>
<td>Datum3</td>
<td>Datum4</td>
<td>Datum5</td>
</tr>
<tr>
<td>Datum1</td>
<td>Datum2</td>
<td>Datum3</td>
<td>Datum4</td>
<td>Datum5</td>
</tr>
<tr>
<td>Datum1</td>
<td>Datum2</td>
<td>Datum3</td>
<td>Datum4</td>
<td>Datum5</td>
</tr>
</tbody>
</table>
</div>
<div class="sticky sticky-bottom">
I'm a...
CSS
body{
display: flex;
width : 100vw;
height: 100vh;
justify-content: center;
text-align: center;
flex-direction: column;
}
.floating-middle{
align-self : center;
width : 200px;
height : 200px;
border: 1px solid black;
resize: both;
overflow: auto;
}
.sticky-top{
position: sticky;
top: 0;
border-bottom: 1px solid black;
}
.sticky-bottom{
position: sticky;
bottom: 0;
border-top: 1px solid black;
}
.sticky{
background: red;
color: white;
}
table{
width: 100%;
overflow: auto;
}