table元素的td和ul元素li隔行变色

table的css样式控制:

table tr td{

background-color:颜色1

}

table tr td:nth-child(2n+1){

background-color:颜色2

}

ul的li样式控制

ul li{

background-color:颜色1;

}

ul li:nth-child(2n+1){

background-color:颜色2;

}

table tr:nth-child(odd){
color: aqua;
}
table tr:nth-child(even){
color: coral;
}

原文地址:https://www.cnblogs.com/xiejn/p/13846667.html