I enjoy using hoverable tables, but I've noticed a strange behavior when including the table-dark
class in my <thead>
. It seems to make the header row behave like a body row, which is not what I want. Is this standard behavior and is there a way to have both dark headings and hoverable tables in Bootstrap 4 without resorting to manual adjustments like
class="bg-dark text-light"
?
Just for fun, try adding the table-dark
class to the thead tr
element and witness the unexpected results (quite weird!)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Admin Page</title>
</head>
<body>
<div class="container">
<div class="row">
<table class="table table-hover text-center">
<thead class="table-dark">
<tr>
<th scope="col">Name</th>
<th scope="col">Last name</th>
<th scope="col">Department</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>IT</td>
</tr>
<tr>
<td>Jane</td>
<td>Doe</td>
<td>HR</td>
</tr>
</tbody>
</table>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>