html - 如何在 Bootstrap 中悬停时设置 td 颜色?

标签 html css twitter-bootstrap

默认情况下,Twitter Bootstrap.table-hover 中的表格使用样式:

.table-hover > tbody > tr:hover {
  background-color: #f5f5f5;
}

是否可以这样做:

.table-hover > tbody > tr:hover > td:first-child {
    background-color: inherit !important;
}

只有 tr 的第一个 td 不会在 hover 上改变?

最佳答案

问题是 Bootstraps 为 tr 的背景着色.为了覆盖它,您需要为 td 着色与页面的背景颜色。

.table-hover > tbody > tr:hover td:first-child {
    background-color: #fff;
}

使用透明背景是行不通的,因为 tr 的背景色位于其下方。

DEMO .



你可以使用 nth-child选择器,选择行中的所有单元格,但第一个:

.table-hover > tbody > tr:hover td:nth-child(n+2) {
  background-color: #f5f5f5;
}

<罢工> DEMO

关于html - 如何在 Bootstrap 中悬停时设置 td 颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30046919/

相关文章:

javascript - 如何在 jquery 中更改 bootstrap glyphicon 颜色

javascript - 如何克隆实际的 iFrame 内容,而不仅仅是 iFrame 标签内容?

css - Dreamweaver CSS - 文本不会换行

javascript - 具有最小副作用的非 Canvas 移动导航

javascript - 如何仅在设备处于 xs View 时添加点击处理程序?

django - 如何将 Django forms.ChoiceField 呈现为 Twitter Bootstrap 下拉菜单

javascript - 在 Javascript 中模拟群组列表上的按钮单击

java - JAVA中如何从html文件中获取特定数据

html - 如何使用 CSS 强制图像响应以使其保持在同一位置?

html - 制作一个带有内联按钮的div