Reputation: 43
I would like to create my table to work like this:
I have tried the following code but it does not work:
<section class="signa-table-section clearfix">
<div class="container">
<div class="row">
<div class="col-lg">
<table class="table table-responsive table-bordered">
<thead>
<tr>
<th>Entry</th>
<th>Sl</th>
<th colspan="3">Tp</th>
<th>Tp</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
<td>Mark</td>
<td>Otto</td>
</tr>
<tr>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
<td>Mark</td>
<td>Otto</td>
</tr>
<tr>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
<td>Mark</td>
<td>Otto</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
Upvotes: 5
Views: 16935
Reputation: 5283
In order to achieve the desired division inside your table head, you need to basically create a new table within the head and divide that one.
Your <th>
would look like the following:
<th colspan="3" class="custom-header">
<table class="table table-responsive">
<thead>
<tr>
<th colspan="3" class="last">Tp</th>
</tr>
<tr>
<th>Tp1</th>
<th>Tp2</th>
<th class="last">Tp3</th>
</tr>
</thead>
</table>
</th>
Then you need to play around with CSS until the result looks just right, you want to tamper with margin, padding, border and width. Here is a codepen with a proposed solution.
Upvotes: 0
Reputation: 2748
Replace inside your <thead>
by :
<tr>
<th rowspan="2">Entry</th>
<th rowspan="2">Sl</th>
<th colspan="3">Tp</th>
</tr>
<tr>
<th>Tp</th>
<th>Tp</th>
<th>Tp</th>
</tr>
Upvotes: 1