Bootstrap的深色桌头变得可悬停。我可以对此做点什么(除了手动指定样式)吗?



我喜欢可悬浮的表格。但是我注意到,如果我在<thead>元素中包含table-dark类(我也喜欢深色表标题),它就会变得可悬浮,就像它是一个主体行一样(这是愚蠢的)。如果我把它去掉,一切都会好起来的。这是标准行为吗?我可以在Bootstrap 4中具有黑色标题的可悬浮表而无需诉诸class="bg-dark text-light"等手动措施吗?

另外,只是为了好玩,尝试将table-dark类添加到thead tr元素,看看会发生什么(奇怪的东西!)

<!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@3.6.3/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

你只需要改变head的class,它应该是' head-dark',

需要更改行号。13 code<thead class="thead-dark">

你可以检查这支笔:https://codepen.io/himanipanchal/pen/LYgVRYg

最新更新