I would like the first two columns to only occupy the width of their contents, and for the final 3rd column to be justified to the right with a gap (if any) between the 2nd and 3rd columns as immediately below. In the diagram I have marked this as a large empty column.
+-------+------+-------------------+------+
| Col1 | Col2 | | Col3 |
+-------+------+-------------------+------+
| Val 1 | Val2 | | Val3 |
+-------+------+-------------------+------+
Some restraints:
I can use only bootstrap.
I cant use any custom styles.
I've tried it as follows, but it's not working.
<table class="table table-bordered">
<thead>
<tr class="row">
<td class="col-md-1">col1</td>
<td class="col-md-1">col2</td>
<td class="col-md-9"></td>
<td class="col-md-1">col3</td>
</tr>
</thead>
<tbody>
<tr class="row">
<td class="col-md-1">val1</td>
<td class="col-md-1">val2</td>
<td class="col-md-9"></td>
<td class="col-md-1">val3</td>
</tr>
</tbody>
</table>
Bootstrap 4
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
</tbody>
</table>
Bootstrap 3
<table class="table table-bordered">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>john#example.com</td>
</tr>
<tr>
<td>Mary</td>
<td>Moe</td>
<td>mary#example.com</td>
</tr>
<tr>
<td>July</td>
<td>Dooley</td>
<td>july#example.com</td>
</tr>
</tbody>
</table>
Check which version you are using for bootstrap. If any of the above code is not working please check you imported the bootstrap properly or not.
Related
<table class="table">
<thead>
<tr class="d-flex">
<th class="col-0">JOB ID</th>
<th class="col-0">JOB STATUS</th>
<th class="col-0">USER</th>
<th class="col-0">BG TASK STATUS</th>
<th class="col-2">BG TASK RESULT</th>
<th class="col-0">BG TASK CREATED TIME</th>
<th class="col-0">BG TASK COMPLETED TIME</th>
<th class="col-0">DETAIL LOG LINK</th>
</tr>
</thead>
<tbody>
<tr class="d-flex">
<td class="col-0">15</td>
<td class="col-0">success</td>
<td class="col-0">None</td>
<td class="col-0"></td>
<td class="col-2"></td>
<td class="col-0"></td>
<td class="col-0"></td>
<td class="col-0">Job Details</td>
</tr>
</tbody>
</table>
Delete the className="d-flex" in tr tag
You can add the class text-justify to the table so that the text will be aligned to center
How would I go about setting up an html table to use sticky headers and set the stickyHeaderOffsetY option.
The examples for
https://bootstrap-table.com/docs/extensions/sticky-header/ all assume you're using javascript to populate the tables and I cannot find any documentation on how to set the options any other way.
This is as far as I have gotten:
<table
data-toggle="table"
data-search="true"
data-sticky-header="true"
data-sortable="true"
data-show-columns="true"
class="table table-striped table-hover table-condensed">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>john#example.com</td>
</tr>
<tr>
<td>Mary</td>
<td>Moe</td>
<td>mary#example.com</td>
</tr>
<tr>
<td>July</td>
<td>Dooley</td>
<td>july#example.com</td>
</tr>
</tbody>
</table>
Sorry I cant comment, but do you try this?
<table
data-sticky-header="true"
data-sticky-header-offset-y="60"
></table>
I'm aware of table-responsive class but it's not working here and it's breaking the UI.
My code looks like this:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<table id="home-table">
<tr>
<td class='home-cell'>
<table class="table table-bordered">
<caption>Overview</caption>
<thead>
<tr>
<th>Device ID</th>
<th>Last Reading</th>
</tr>
</thead>
<tbody>
<tr>
<td>Demo 1</td>
<td>Reading: R1</td>
</tr>
</tbody>
</table>
</td>
<td class='home-cell'>
<table class="table table-bordered">
<caption>Alarms and Schedules</caption>
<thead>
<tr>
<th>Device ID</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<td>Dev 1</td>
<td>Scheduled 10:00 AM OFF</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
How can I achieve separate responsive horizontal scrollbars in both the tables inside the main table?
you can do it like this
<style>
.home-cell.table-responsive {
width: 150px;
overflow: auto !important;
display: inline-block;
}
table .table-bordered {
width: 190px;
min-width: 270px;
}
</style>
<table id="home-table">
<tbody>
<tr>
<td class="home-cell table-responsive">
<table class="table table-bordered">
<caption>Overview</caption>
<thead>
<tr>
<th>Device ID</th>
<th>Last Reading</th>
</tr>
</thead>
<tbody>
<tr>
<td>Demo 1</td>
<td>Reading: R1</td>
</tr>
</tbody>
</table>
</td>
<td class="home-cell table-responsive">
<table class="table table-bordered">
<caption>Alarms and Schedules</caption>
<thead>
<tr>
<th>Device ID</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<td>Dev 1</td>
<td>Scheduled 10:00 AM OFF</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
Try this, This will work
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="table-responsive">
<table class="table table-bordered">
<th colspan="3">Outer Table</th>
<tr>
<td>This is row one, column 1</td>
<td>This is row one, column 2</td>
<td>
<table class="table table-bordered">
<th colspan="3">Inner Table</th>
<tr>
<td>This is row one, column 1</td>
<td>This is row one, column 2</td>
<td>This is row one, column 3</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
https://jsfiddle.net/DTcHh/38830/
Is it possible to separate each row using a margin, in a striped table in bootstrap v4. I want each row to spaced out a little to be more readable.
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>#mdo</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Jacob</td>
<td>Thornton</td>
<td>#fat</td>
</tr>
<tr>
<th scope="row">3</th>
<td>Larry</td>
<td>the Bird</td>
<td>#twitter</td>
</tr>
</tbody>
</table>
Table rows does not have margin values. You may consider to use padding values to td.
For reference :
.table td{
padding-bottom: 10px;
}
I have a nested table inside a table which is nestedTable and it does not show up in IE7 even though it exists in the html and display is not none. Below is my html which seems to be valid and working in Firefox, Chrome and IE8:
<table id="myTable">
<thead> ... </thead>
<tbody class="myTbody1">
<tr class="details">
<td>
<table id="nestedTable">
<thead>
<tr>
<th> Col1 </th>
<th> Col2 </th>
</tr>
</thead>
<tbody class="head">
<tr class="nestedRow">
<td> Data</td>
<td> Data</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
<tbody class="myTbody2">..</tbody>
<tbody class="myTbody3">..</tbody>
</table>