I'm currently working on implementing alternating background colors for columns in a table. I have successfully applied CSS to a simple table, but I am facing issues when dealing with more complex tables that involve rowspan and colspan. Can anyone offer guidance on how to approach fixing this issue?
The tables I am working with are all generated by someone else, so I do not have control over the HTML structure. The challenge is to create CSS that will work universally across all these tables.
You can view my CSS code in action at the following links:
or
http://codepen.io/anon/pen/ORPLgz
table.specialtable {
border-top: 2px solid #00ABEF;
border-bottom: 2px solid #00ABEF;
background-colo: #FFF;
font-size: 11px;
}
table.specialtable th {
background-color: #B8E5FA;
border-right: 1px solid #FFF;
border-left: 1px solid #FFF;
padding: 4px 2px;
}
table.specialtable td {
padding: 4px 2px;
text-align: center;
}
table.specialtable td:first-child {
text-align: left;
}
table.specialtable td:nth-child(even){
background-color: #E2F4FE;
}
table.specialtable td:nth-child(odd){
background-color: #FFF;
}