我正在尝试一个简单的技巧来改变响应式表格的悬停颜色,但失败了。
我尝试链接 CSS 但失败了。
我是否需要添加更多 CSS 标签来实现这一点。
你能帮我理解我的方法有什么问题吗?
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
.table-hover thead tr:hover th, .table-hover tbody tr:hover td {
background-color: #FF0000;
}
</script>
</head>
<body>
<div class="container">
<h2>Table</h2>
<p>The .table-hover class enables a hover state on table rows within a tbody:</p>
<table class="table table-hover">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>[email protected]</td>
</tr>
<tr>
<td>Mary</td>
<td>Moe</td>
<td>[email protected]</td>
</tr>
<tr>
<td>July</td>
<td>Dooley</td>
<td>[email protected]</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
您必须在 CSS 上放置样式而不是脚本
在这里实现:
<style>
.table-hover thead tr:hover th, .table-hover tbody tr:hover td {
background-color: #FF0000;
}
</style>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句