I would like to use CSS flexbox on a containing DIV of two tables, and making one of the tables fill the available space using flex-grow. However, it doesn't grow. It seems as though this is because the tables aren't block display elements. I have it working if I wrap the TABLEs inside DIVs. However, I wonder if there is anyway to get this to work without the extra DIVs?
Below is an example - the first container is without the DIVS, the second is with DIVs and has the desirable layout.
div.container {
display: flex;
background-color: red;
}
#nodivs table:first-child {
background-color: green;
}
#nodivs table:last-child {
background-color: blue;
flex-grow: 1;
}
#divs div:first-child {
background-color: green;
}
#divs div:last-child {
background-color: blue;
flex-grow: 1;
}
#divs div:last-child table {
width: 100%
}
<div id="nodivs" class="container">
<table>
<thead>
<tr><th>T1C1</th><th>T1C2</th><th>T1C3</th></tr>
</thead>
</table>
<table>
<thead>
<tr><th>T2C1</th><th>T2C2</th><th>T2C3</th></tr>
</thead>
</table>
</div>
<br><br>
<div id="divs" class="container">
<div><table>
<thead>
<tr><th>T1C1</th><th>T1C2</th><th>T1C3</th></tr>
</thead>
</table></div>
<div><table>
<thead>
<tr><th>T2C1</th><th>T2C2</th><th>T2C3</th></tr>
</thead>
</table></div>
</div>