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-default
classes 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
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
Be sure you are using < th > instead < td > into header.
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>
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;
}
Easy enough. The CSS sheet you're linking to in your fiddle doesn't include the .table-inverse
styling.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With