【发布时间】:2018-01-25 06:28:14
【问题描述】:
我尝试了一个简单的技巧来改变响应式表格的悬停颜色,但失败了。
我尝试链接 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>john@example.com</td>
</tr>
<tr>
<td>Mary</td>
<td>Moe</td>
<td>mary@example.com</td>
</tr>
<tr>
<td>July</td>
<td>Dooley</td>
<td>july@example.com</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
【问题讨论】:
-
对我来说效果很好
-
谢谢杰森。您能否确认您是否能够在悬停时看到红色或灰色。实际上我想要悬停时的红色,但我可以看到灰色
标签: css colors html-table hover responsive