html 一行中不同颜色,html – CSS表中第一行和第一列的每个单元格的背景颜色不同...

您可以修改第一列中每个单元格的颜色,而无需修改HTML,方法是将tr上的nth-child和td上的first-child组合在一起,如下所示:

table.agenda tr:nth-child(1) td:first-child {

background: rgb(16,20,50);

color: white;

}

table.agenda tr:nth-child(2) td:first-child {

background: rgb(16,150);

color: white;

}

table.agenda tr:nth-child(3) td:first-child {

background: rgb(16,255);

color: white;

}

现场演示:

table.agenda {

font-family: "Trebuchet MS",sans-serif;

border-collapse: collapse;

width: 100%;

}

table.agenda td,table.agenda th {

border: 1px solid #fff;

padding: 8px;

text-align: center;

}

table.agenda td {

padding-top: 12px;

padding-bottom: 12px;

background-color: rgb(193,174);

color: black;

}

th:nth-child(1) {

background: white;

}

th:nth-child(2) {

background: rgb(72,54);

color: white;

}

th:nth-child(3) {

background: rgb(84,64);

color: white;

}

th:nth-child(4) {

background: rgb(97,73);

color: white;

}

th:nth-child(5) {

background: rgb(110,82);

color: white;

}

th:nth-child(6) {

background: rgb(120,91);

color: white;

}

table.agenda tr:nth-child(1) td:first-child {

background: rgb(16,255);

color: white;

}

August 4August 5August 6August 7August 8

MorningDay 1 MorningDay 2 MorningDay 3 MorningDay 4 MorningDay 5 MorningAfternoonDay 1 AfternoonDay 2 AfternoonDay 3 AfternoonDay 4 AfternoonDay 5 AfternoonEveningDay 1 EveningDay 2 EveningDay 3 EveningDay 4 EveningDay 5 Evening
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值