CSS表td颜色

时间:2016-10-10 16:10:25

标签: html css

我在Wordpress Tablepress插件中使用它。

我有这些代码来突出显示表格行。无论如何,我可以将它们合并为单行以减少重复的代码吗?

.tablepress-id-1 .row-2 td {
	background-color: #000000;
	color: #ffffff;
}

.tablepress-id-1 .row-13 td {
	background-color: #000000;
	color: #ffffff;
}

.tablepress-id-1 .row-15 td {
	background-color: #000000;
	color: #ffffff;
}

.tablepress-id-1 .row-19 td {
	background-color: #000000;
	color: #ffffff;
}

.tablepress-id-1 .row-23 td {
	background-color: #000000;
	color: #ffffff;
}

.tablepress-id-1 .row-26 td {
	background-color: #000000;
	color: #ffffff;
}

.tablepress-id-1 .row-35 td {
	background-color: #000000;
	color: #ffffff;
}

.tablepress-id-1 .row-35 td {
	background-color: #000000;
	color: #ffffff;
}

2 个答案:

答案 0 :(得分:4)

您可以使用逗号分隔多个CSS选择器:

.tablepress-id-1 .row-2 td,
.tablepress-id-1 .row-13 td,
.tablepress-id-1 .row-15 td
{
  background-color: #000000;
  color: #ffffff;
}

答案 1 :(得分:3)

只需将相同的类应用于要设置样式的元素即可。并将其插入到您的css文件中。

.identicalClass {
 background-color: #000000;
 color: #ffffff;
}