Code:
HTML
<body>
<header>
"..."
</header>
<main>
<div class="searchBox">
<table>
"..."
</table>
</div>
<div class="tableData">
<table>
"..."
</table>
</div>
</main>
</body>
The searchBox
is not important. I just put it there to show that there is something above my other table (tableData
).
What I am trying to achieve is to get tableData
to fill the rest of the screen height visible so no scroll bars are required.
I have researched and come across multiple solutions but none of these seem to work:
1. Set 'vh' property
Even though this goes off the viewport dimensions it's pretty good. However, I have a tabbed UI with all tabs having tableData
displayed but at different positions on the page. This means that switching from tab to tab, tableData
does not have time to render the new dimensions. Example sketch below:
So if I base the height of tableData
on the image on the left where the content above is smaller, then the height of tableData
will be too big and over-stretch on the other tab where the position of it has changed
2. Using absolute positioning
I immediately wrote this off as I also want my page to be responsive upon different devices and I understand that using absolute positioning can mess that up
3. Flexbox
I have been following this post for this method: Make a div fill the height of the remaining screen space
I have tried this approach but it removed all of my other CSS I had on the page.
What is the best way to achieve what I want?