Looking for a way to make tables in Django using django-tables2 stick to the top of the page as you scroll down? Check out some relevant code snippets below:
tables.py
class Example(tables.Table):
field1 = tables.Column()
field2 = tables.Column()
field3 = tables.Column()
class Meta:
attrs = {'class': 'table table-striped', 'style': 'display: block; overflow: auto;'}
example.html
<style></style>
<table>
<thead>
<tr>
<td>Field1</td>
<td>Field2</td>
<td>Field3</td>
</tr>
</thead>
<tbody>
<tr>
<td>Text</td>
<td>Text</td>
<td>Text</td>
</tr>
</tbody>
</table>
<script></script>
Struggling with getting the headers to stick after scrolling with CSS and JavaScript? Share your solutions or ask for help - I'm using jquery-3.2.1. Thanks!