After some trial and error, I managed to make this work on my own! The solution involves adding a box shadow and a fixed header on the table. Hopefully, this code snippet will be useful to someone who needs it.
CSS:
.shadow {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.jumbotron {
padding: 2rem 1rem;
}
tbody {
display: block;
height: 20rem;
overflow: scroll;
}
thead,
tbody tr {
display: table;
width: 100%;
table-layout: fixed;
}
HTML:
<div class="shadow">
<table class="table table-hover">
<thead class="thead-info">
<tr>
<th>Title</th>
<th>Artist</th>
<th>Key</th>
</tr>
</thead>
<tbody infiniteScroll [infiniteScrollDistance]=".1" [infiniteScrollThrottle]="50" (scrolled)="onScroll()" [scrollWindow]="false">
<div *ngIf="!tuneService.tunes" class="text-center justify-content-center">
<h2>Loading...</h2>
</div>
<tr *ngFor="let tune of page.data | async" routerLink="/tune-details/{{tune.id}}">
<td>{{tune.title}}</td>
<td>{{tune.artist}}</td>
<td>{{tune.musicalKey}}</td>
</tr>
<app-spinner *ngIf="page.loading | async"></app-spinner>
</tbody>
</table>
</div>