I have a table that is created dynamically using Javascript / jQuery. The logic of which can be seen below:
$.each(input, function (key, value){
let parent = $('<tr>');
let container = $('<td>').text('Test');
parent.append(container);
table.append(parent);
});
Before I began creating the table dynamically I was able to have both a header and footer remain in view while having the table scroll when its height became too large. I did this with the following:
//HTML
<body>
<div id="wrapper">
<div id="header"></div>
<table id="content"></table>
<div id="footer"></div>
</div>
</body>
//CSS
body {
margin: 0;
height: 100%;
}
#wrapper {
height: 100vh;
display: grid;
grid-template-rows: 56px 1fr 100px;
}
#content {
overflow-y: auto;
overflow-x: auto;
}
Although now, with the dynamic table, neither my header nor my footer will stay in view while scrolling.
To attempt to fix this I tried resetting the CSS once my page was loaded but this was unsuccessful. How can I created a fixed/sticky header & footer while still keeping my table dynamic?
Edit: I am looking for a solution that doesn't require setting a static height for the table.