【问题标题】:Bootstrap table-hover for all rows, not just every other所有行的引导表悬停,而不仅仅是其他行
【发布时间】:2014-11-27 17:15:55
【问题描述】:

我正在使用 Bootstrap 3 并将 table-striped table-hover 应用于我的表类。

但是,我已将默认条纹颜色更改为绿色。所以我的专栏有绿 - 白 - 绿 - 白。

现在,当我悬停时,白色变成蓝色。这可以。但是当我将鼠标悬停在绿色上时,它会保持绿色。

如何让每一行在悬停时显示#ecf3f8

我试过没有用:

.table-hover tbody tr.odd:hover td, .table-hover tbody tr.odd:hover th {
  background-color: #ecf3f8;
}

【问题讨论】:

标签: css twitter-bootstrap-3


【解决方案1】:

试试这个:

.table-hover tbody tr:hover td {
  background: #ecf3f8 !important;
}

编辑:也试试这个:

.table-hover > tbody > tr:hover > td {
  background: #ecf3f8 !important;
}

【讨论】:

  • 如果你上面提到的类是正确的,它应该是。
  • 使用了简单的表格,不用大惊小怪,这些都没有效果,在bootply中尝试(我不是OP);)
  • 简单表没有'table-hover'类
【解决方案2】:

听起来像是一个特异性问题。请尝试以下操作:

.table-striped.table-hover>tbody>tr:hover>td, 
.table-striped.table-hover>tbody>tr:hover>th {
  background-color: #ecf3f8;
}

【讨论】:

  • 真的,我错过了table-hover
  • 我的解决方案在有或没有table-hover 的情况下都适用;)
  • @webeno 我尽可能避免使用!important。我看到的唯一有效用途是覆盖 javascript 注入的内联样式。
【解决方案3】:

试试这个:

.table-striped tbody tr:hover td,
.table-striped tbody tr:hover th {
    background-color: #ecf3f8
}

你可以在这里试试:http://www.bootply.com/2Gp7XHJ9jV

来源:https://github.com/twbs/bootstrap/issues/3223#issuecomment-5735608

【讨论】:

  • 我上网寻找您的解决方案。
  • @marto 我很高兴能帮上忙 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-05-16
  • 2013-12-23
  • 2014-12-08
  • 1970-01-01
  • 2012-02-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多