Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap inverse table and thead not styling correctly

While working on a Bootstrap-based project, I came across a strange issue where some of the styling was being overridden by the user agent stylesheet (in Chrome and Firefox). I found this related issue, which was solved by including the <!DOCTYPE html> tag I had initially omitted. But now I can't get the .table-inverse, .thead-inverse, or .thead-defaultclasses to shade my table headers. As far as I understand, I have all the necessary rows, containers, etc in place.

Why isn't the shading working?

.navbar {
  border-radius: 0px
}
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />

<h2 class="display-1">Bootstrap 4 Inverse Table</h2>

<div class="container">
  <div class="row">
    <div class="col-md-6 col-md-offset-3">
      <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>
    </div>
  </div>
</div>

View on JSFiddle

like image 730
Bradley Parker Avatar asked Feb 05 '16 21:02

Bradley Parker


5 Answers

For anyone like me finding this thread but using Bootstrap 4.0.0-beta.2 or later, table-inverse and thead-inverse have been replaced with -dark per the version release information linked here

like image 189
superbeck Avatar answered Nov 11 '22 18:11

superbeck


Be sure you are using < th > instead < td > into header.

like image 23
Edgar Diaz Avatar answered Nov 11 '22 18:11

Edgar Diaz


You have to add bootstrap-X.X-flex.css too.

bootstrap-X.X.css
bootstrap-X.X-flex.css
bootstrap.js

Where X.X is the version number

OR

Use this CDNs:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha/js/bootstrap.min.js"></script>
like image 12
Pmpr.ir Avatar answered Nov 11 '22 18:11

Pmpr.ir


It happens for the older versions of bootstrap only. Because the class thead-inverse is not available there. You can just add this design to your design css I hope it will definitely work as I have done so. The reason behind this is thead-inverse is only available in recent versions of bootstrap.css only.

.thead-inverse th {
            color: #fff;
            background-color: #373a3c;
        }
like image 4
gdmanandamohon Avatar answered Nov 11 '22 19:11

gdmanandamohon


Easy enough. The CSS sheet you're linking to in your fiddle doesn't include the .table-inverse styling.

like image 2
Eric Foster Avatar answered Nov 11 '22 19:11

Eric Foster