Html 使用 css 突出显示选定的行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5154955/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Highlight selected row using css
提问by Null Pointer
How we can highlight selected row in a table using css. Is there any way to do that?
我们如何使用 css 突出显示表格中的选定行。有没有办法做到这一点?
采纳答案by Quentin
tr { background: sky-blue-pink } /* Use a real colour */
tr * { background: transparent; }
where tr
is a more specific selector to indicate whatever condition you have in the DOM to represent 'selected'. This will probably be a class selector: tr.selected
wheretr
是一个更具体的选择器,用于指示您在 DOM 中拥有的任何条件来表示“已选择”。这可能是一个类选择器:tr.selected
回答by Munneson
Assuming that by "selected" you mean "hovered over by mouse":
假设“选定”是指“鼠标悬停”:
tr:hover {background-color: #FF0000}
You could also highlight with things like 'font-weight:bold', 'color: #FF000', etc..
您还可以使用诸如“font-weight:bold”、“color:#FF000”等来突出显示。
回答by Trufa
回答by DHRUV BANSAL
CSS part:
CSS部分:
table.rowHover tr:hover{ background-color: #ccc; }
apply class = "rowHover" on the table
cheers !!!
干杯!!!