hot*_*arl 0 html css css-tables
我正在尝试在一个 html 页面上选择一个特定的表格,以使用 css 进行格式化。我不希望其他地方的任何其他表格(包括同一页面上的表格)以这种方式格式化。
我在标题中尝试了这个,但没有成功-
<style>
#table3 {
td,th { padding: 10px }
tr:hover { background-color: #f5f5f5 }
}
</style>
<table id="table3">
...
</table>
Run Code Online (Sandbox Code Playgroud)
你不能像那样嵌套选择器。至少在普通 CSS 中不是这样。
你要:
<style>
#table3 td, #table3 th { padding: 10px }
#table3 tr:hover { background-color: #f5f5f5 }
</style>
<table id="table3">
...
</table>
Run Code Online (Sandbox Code Playgroud)