小编Chr*_*Cox的帖子

CSS 表格交替行颜色和悬停颜色

我有一张带班级表的表。到目前为止唯一的样式是 table th。我想使用 CSS 值在行的白色和银色之间交替,并为整行悬停银色。有没有人有代码?


<table class='table'>
  <tr>
   <th>heading</th>
   <th>heading 2</th>
   <th>heading 3</th>
  </tr>
  <tr class='table'>
    <td>col 1</td>
    <td>col 2</td>
    <td>col 3</td>
  </tr>
  <tr class='table'>
    <td>col 1</td>
    <td>col 2</td>
    <td>col 3</td>
  </tr>
  <tr class='table'>
    <td>col 1</td>
    <td>col 2</td>
    <td>col 3</td>
  </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

那是 html 示例(因为它是用 php 编写的)

CSS

.table {
background-color: #FFFFFF;
color: #000000;
}

.table th {
background-color: #333333;
color: #FFFFFF;
}
Run Code Online (Sandbox Code Playgroud)

到此为止。寻找用于我猜测表 tr css 的值。


说不同是因为偶数/奇数不起作用&它是动态的php而不是严格的html。

css html-table styling

2
推荐指数
1
解决办法
3万
查看次数

标签 统计

css ×1

html-table ×1

styling ×1