I have a parent table with three child tables. In the main table I want to display a row from the parent and a second row with nested tables from the three children and have all this be responsive.
My problem is the three nested tables align with columns from the main table and I cant figure out a way to decouple them from the main table columns as the screen size shrinks. I'd like the child tables to stack as the parent columns shrink down to fit in the width. Any ideas would be appreciated!
I'm using jquery and Bootstrap 3. I was going to use jsFiddle to show an example but it looks like I can embed it right here now! Just click on the run code button.
.parent {
background-color: lightblue;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<table>
<thead>
<tr class="parent">
<th>parent col1</th>
<th>parent col2</th>
<th>parent col3</th>
<th>parent col4</th>
</tr>
</thead>
<tbody>
<tr class="parent">
<td>parent row1 data1</td>
<td>parent row1 data2</td>
<td>parent row1 data3</td>
<td>parent row1 data4</td>
</tr>
<tr>
<td></td>
<td>
<table class="table table-responsive table-condensed">
<thead>
<tr>
<th>child1 col 1</th>
<th>child1 col 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>child1 row1 data 1</td>
<td>child1 row1 data 2</td>
</tr>
</tbody>
</table>
</td>
<td>
<table class="table table-responsive table-condensed">
<thead>
<tr>
<th>child2 col 1</th>
<th>child2 col 1</th>
</tr>
</thead>
<tbody>
<tr>
<td>child2 row1 data 1</td>
<td>child2 row1 data 2</td>
</tr>
</tbody>
</table>
</td>
<td>
<table class="table table-responsive table-condensed">
<thead>
<tr>
<th>child3 col 1</th>
<th>child3 col 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>child3 row1 data1</td>
<td>child3 row1 data2</td>
</tr>
<tr>
<td>child3 row2 data1</td>
<td>child3 row2 data2</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr class="parent">
<td>parent row2 data1</td>
<td>parent row2 data2</td>
<td>parent row2 data3</td>
<td>parent row2 data4</td>
</tr>
<tr>
<td></td>
<td>
<table class="table table-responsive table-condensed">
<thead>
<tr>
<th>child1 col 1</th>
<th>child1 col 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>child1 row1 data 1</td>
<td>child1 row1 data 2</td>
</tr>
</tbody>
</table>
</td>
<td>
<table class="table table-responsive table-condensed">
<thead>
<tr>
<th>child2 col 1</th>
<th>child2 col 1</th>
</tr>
</thead>
<tbody>
<tr>
<td>child1 row1 data 1</td>
<td>child1 row1 data 2</td>
</tr>
</tbody>
</table>
</td>
<td>
<table class="table table-responsive table-condensed">
<thead>
<tr>
<th>child3 col 1</th>
<th>child3 col 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>child3 row1 data1</td>
<td>child3 row1 data2</td>
</tr>
<tr>
<td>child3 row2 data1</td>
<td>child3 row2 data2</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr class="parent">
<td>parent row3 data1</td>
<td>parent row3 data2</td>
<td>parent row3 data3</td>
<td>parent row3 data4</td>
</tr>
<tr>
<td></td>
<td>
<table class="table table-responsive table-condensed">
<thead>
<tr>
<th>child1 col 1</th>
<th>child1 col 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>child1 row1 data 1</td>
<td>child1 row1 data 2</td>
</tr>
</tbody>
</table>
</td>
<td>
<table class="table table-responsive table-condensed">
<thead>
<tr>
<th>child2 col 1</th>
<th>child2 col 1</th>
</tr>
</thead>
<tbody>
<tr>
<td>child2 row1 data 1</td>
<td>child2 row1 data 2</td>
</tr>
</tbody>
</table>
</td>
<td>
<table class="table table-responsive table-condensed">
<thead>
<tr>
<th>child3 col 1</th>
<th>child3 col 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>child3 row1 data1</td>
<td>child3 row1 data2</td>
</tr>
<tr>
<td>child3 row2 data1</td>
<td>child3 row2 data2</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>