Twitter bootstrap 去掉了表格上的悬停背景颜色
我花了 45 分钟研究如何消除行悬停时的背景颜色变化.
I've spent 45min looking on how to remove the background color change on row hover.
见小提琴:http://jsfiddle.net/BJrnC/1/
以防万一我不清楚.当您使用引导程序在表格的 tbody 中悬停一行时,背景会变为灰色.问题是我真的很喜欢他们的布局,但我就是不喜欢那样.
Just in case I'm not clear. When you hover a row in the tbody of a table using bootstrap, the background goes to grey. The problem is that I really like the layout they have, but I just don't like that.
如何禁用它?
谢谢.
您可以在样式表中添加以下内容以覆盖该功能:
You can add the following on your stylesheet to overwrite that feature:
.table tbody tr:hover td, .table tbody tr:hover th {
background-color: transparent;
}
演示:http://jsfiddle.net/BJrnC/2/
注意:注意到我仍然为这个答案点赞.推特引导程序现在默认执行此操作.如果您想向表格添加悬停效果,只需将 .table-hover
悬停类添加到您的表格主体,否则只需省略它,它在悬停时不应有任何效果.这仅适用于最新版本的引导程序.
Note: Noticed that I'm still getting upvoted for this answer. The twitter bootstrap now does this by default. If you want to add hover effects to a table simply add the .table-hover
hover class to the body of your table, otherwise just omit it and it should not have any effects when hovered. This only applies to the latest version of the bootstrap.