Lightbox2.com

Bootstrap Table Nested

Overview

Tables are present in a lot of apps (web, desktop or mobile application) and they are a important component in showing information to the final user. The HTML tables are actually used to present data in framework way such as rows and columns . With using Bootstrap 4 framework you are capable to easily improve the appearance of the table.

In the present day, with the importance that the user interface has, knowing precisely how to increase the look of a Bootstrap table becomes as relevant as it is. In this case, one of the technologies that have come to be reference is Bootstrap. This front-end framework, within a lot of other features , gives a variety of elements for styling and optimising the display of various components, such as tables.

Main table in Bootstrap

To style a table through Bootstrap, just include the table class to the

<table>
tag, and certain visional formatting will currently be applied , as pointed on the screenshot .

Bootstrap basic table

<table class="table">
  <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>

Inverse tables.

One of the new tables in Bootsrap 4 is the inverse tables. Class

.table-inverse
can certainly restyle the coloring of the table.

Bootstrap inverse table
<table class="table table-inverse">
  <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>

Additional classes

For tables there are additionally some classes that help you to add other designs to a table ( see page), they are:

table-striped
Toggles the colour of table rows;

table-bordered
Adds border to table;

table-hover
Activates the highlight of a Bootstrap Tables Vertical line when we hover the mouse arrow over it;

table-condensed
Reduces the height of table rows, helping make it more compact.

To use all of these styles, just simply add the wanted classes to the: <table>: <table class="table table-striped table-bordered table-condensed table-hover">

Table head possibilities

Like default and inverse tables, apply one of two modifier classes to get

<thead>
show up light or dark gray.

Table head options
<table class="table">
  <thead class="thead-inverse">
    <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 class="table">
  <thead class="thead-default">
    <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>

Striped rows

Zebra-like stripes may be provided with the

.table-striped
class, an example

Bootstrap striped rows
<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>

Hover Rows

To create a hover side effect in the rows of your table provide the

.table-hover
class ( see page):

Bootstrap hover rows
<table class="table table-hover">
  <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 colspan="2">Larry the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>

Bordered Table

You can easily add the borders on each table slide and a cell through the

.table-bordered
class:

Bootstrap bordered table
<table class="table table-bordered">
  <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>Mark</td>
      <td>Otto</td>
      <td>@TwBootstrap</td>
    </tr>
    <tr>
      <th scope="row">3</th>
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
      <th scope="row">4</th>
      <td colspan="2">Larry the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>

Condensed Table

In case that you intend to make your table a lot more small - then you can cut cell padding in half by having this class:

.table-condensed
.

Note that, while Bootstrap 4 uses

.table-sm
to condense a table, Bootstrap 3 uses
.table-condensed
. Both equally cut cell padding in half.

Bootstrap condensed table
<table class="table table-sm">
  <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 colspan="2">Larry the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>

Contextual Classes of Bootstrap Table Twitter

Use the contextual classes to color a table cells (

<td>
) and table rows (
<tr>
):

Bootstrap contextual classes
<!-- On rows -->
<tr class="table-active">...</tr>
<tr class="table-success">...</tr>
<tr class="table-warning">...</tr>
<tr class="table-danger">...</tr>
<tr class="table-info">...</tr>

<!-- On cells (`td` or `th`) -->
<tr>
  <td class="table-active">...</td>
  <td class="table-success">...</td>
  <td class="table-warning">...</td>
  <td class="table-danger">...</td>
  <td class="table-info">...</td>
</tr>

Changing the rows of a table Bootstrap 3 doesn't work with the

.table-
prefix for its contextual classes. For good example, Bootstrap 3 uses
.active
while Bootstrap 4 uses
.table-active
. Other than that, each of the versions use the identical 5 contextual key words (active, success, info, warning, danger). In this article you can view the description of each and every one possible type:

● active: Uses the focus color tone to the table row or table cell

● success: Indicates a positive or successful action

● info: Indicates a neutral information change or action

● warning: Indicates a notice that you may need care

● danger: Indicates a potentially negative or dangerous action

Responsive Tables

To create a responsive table - use the

.table-responsive
class. Table scrolls in the horizontal position on devices that less than 768px. If the device is larger than 768px wide, then you will see no big difference :

Bootstrap responsive tables

Bootstrap 4 allows you to add the

.table-responsive
class to the actual <table> element. Bootstrap 3 tables required that you add that class to a parent <div> element.

Inspect some on-line video short training relating to Bootstrap 4 tables

Related topics:

Bootstrap Table Styles

__

W3schools:Bootstrap table tutorial

Bootstrap table  article

Bootstrap Tables Lecture

Bootstrap Tables Lecture