我喜欢可悬停的表。但我注意到,如果在<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>
1条答案
按热度按时间f87krz0w1#
你只需要改变头部的类别,它应该是“头部黑暗”,
需要更改第13行代码
<thead class="thead-dark">
您可以查看此笔:https://codepen.io/himanipanchal/pen/LYgVRYg