繁体   English   中英

如何在表格行上方连续显示悬停颜色?

[英]How can I have continuous hover color over table row?

我在ASP.NET Web应用程序中创建了下表:

 .table tbody tr:hover td, .table tbody tr:hover th { background-color: #eeeeea; cursor: pointer; } 
 <table class='table' style='border-collapse:separate; border-spacing:1em;'> <thead> <tr> <th style='text-align:left'></th> <th style='text-align:right'>Pages</th> </tr> </thead> <tbody> <tr> <td>objectives</td> <td>3<td> </tr> </tbody> </table> 

现在,当我将鼠标悬停在表格行上时,将获得以下效果:

截图

如上所示,在表<td>之间将有白色区域。.请问对此有何建议? 如何在整个表格行上定义连续的悬停?

我尝试设置以下内容来更改悬停时的边框颜色,但这没有效果:

.table tbody tr:hover td,
.table tbody tr:hover th {
  background-color: #eeeeea;
  border-color: #eeeeea;
  cursor: pointer;
}

差距来自border-collapse:separate; border-spacing:1em; border-collapse:separate; border-spacing:1em; table ,将其更改为border-collapse:collapse; ,并使用paddingthtd根据需要的间距。

旁注,您忘记了关闭标记中的第二个<td>

 .table tbody tr:hover td, .table tbody tr:hover th { background-color: pink; cursor: pointer; } .table th, .table td { padding: 1em; } 
 <table class='table' style='border-collapse:collapse;'> <thead> <tr> <th style='text-align:left'></th> <th style='text-align:right'>Pages</th> </tr> </thead> <tbody> <tr> <td>objectives</td> <td>3</td> </tr> </tbody> </table> 

尝试给行本身着色,并使单元格透明。

.table tbody tr:hover {
  background-color: #eeeeea;
  cursor: pointer;
}
.table tbody tr td, .table tbody tr th {
  background-color: transparent;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM