css - CSS 表格 - 表格的第一个 td 元素的不同颜色,条纹
问题描述
我设法有条纹行,我也设法只为表格的第一个元素着色,但我不能同时做到这两个!
这是我的代码:
.raceresultscss>tbody>tr>td:first-child:nth-of-type(even){
background-color:black !important;
color:white;
}
.raceresultscss>tbody>tr>td:first-child:nth-of-type(odd){
background-color:#94c946 !important;
color:red;
}
解决方案
这.raceresultscss>tbody>tr>td:first-child:nth-of-type(even)
不存在..第一个孩子总是很奇怪...
你是那个意思吗?
.raceresultscss>tbody>tr:nth-of-type(even)>td:first-child{
background-color:black !important;
color:white;
}
.raceresultscss>tbody>tr:nth-of-type(odd)>td:first-child{
background-color:#94c946 !important;
color:red;
}
<table class="raceresultscss">
<tbody>
<tr>
<td>0</td><td>A</td><td>B</td><td>C</td>
</tr>
<tr>
<td>1</td><td>A1</td><td>B1</td><td>C1</td>
</tr>
<tr>
<td>2</td><td>A2</td><td>B2</td><td>C2</td>
</tr>
<tr>
<td>3</td><td>A3</td><td>B3</td><td>C3</td>
</tr>
</tbody>
</table>
推荐阅读
- neo4j - 指向另一个驱动器上的 Neo4J 图形数据
- vb6 - 编译期间显示的消息框错误,来自 OCX
- ace-editor - Ace 编辑器搜索框上一个/下一个按钮的高度缩小了?
- java - 我无法删除 mysql 表中的所有行
- javascript - 我想停止执行,直到 this.conn.getUserByAlternateNumber 完成工作并返回一个值
- php - post方法中的Php搜索表单不返回数据
- java - pg_advisory_lock 有效,但 pg_try_advisory_lock 无效
- php - 使用 Laravel 的 store() 存储使用 imagecopy() 创建的图像
- laravel - Laravel 在保存时自动更新 Eloquent 字段
- php - 从容器到主机的 Postgres 数据路径映射 - 主机上的数据目录为空