I am facing an issue with a table where I have used tr:nth-child(odd) to alternate row background colors.
HTML
/*-----------#602 SAO Styles-----------------------------*/
/*---------SAO Global------------*/
.sao-pricing-table table {
border-collapse: collapse;
width: 80%;
margin: 0 auto;
background: #ffffff;
}
.sao-pricing-table table td {
height: 20px;
}
table.sao-table {
border-collapse: collapse;
}
/*-----Basic Title Cells---------*/
.sao-top-1 {
border: 0px;
background: #FFFFFF;
height: 40px;
width: 40%;
}
.sao-top-2 {
font-size: 16px;
text-shadow: 2px 4px 3px rgba(0, 0, 0, 0.3);
color: #FFFFFF;
border: 0px solid #a8b5b9;
background-color: #003869;
padding-top: 10px;
padding-bottom: 10px;
text-align: center;
height: 40px;
width: 30%;
}
.sao-top-2-title {
font-size: 110%;
}
.sao-top-2-type {
font-size: 120%;
}
.sao-top-2-price {
font-size: 100%;
}
/*------Gold Title Cells------*/
.sao-top-3 {
font-size: 16px;
text-shadow: 2px 4px 3px rgba(0, 0, 0, 0.3);
color: #FFFFFF;
border: 0px solid #a8b5b9;
background-color: #F2A405;
padding-top: 10px;
padding-bottom: 10px;
text-align: center;
height: ;
width: 30%;
}
.sao-top-3-title {
font-size: 110%;
}
.sao-top-3-type {
font-size: 130%;
}
.sao-top-3-price {
font-size: 100%;
}
/*----Regular Cells-----*/
#sao-table table {
border-collapse: collapse;
width: 100%;
}
th,
td {
padding: 0.25rem;
text-align: center !important;
border: 1px solid #ccc;
height: 20%;
}
tr.sao-zebra:nth-child(odd) {
background: #23282D !important;
}
.sao-feature {
text-align: left !important;
}
/* Checkmark Style-----*/
.sao-checkmark {
font-size: 125%;
color: #F2A405;
text-shadow: 2px 4px 3px rgba(0, 0, 0, 0.2);
}
<div class="sao-pricing-table">
<table class="sao-table">
<thead>
<tr>
<th class="sao-top-1">
</th>
<th class="sao-top-2">
<span class="sao-top-2-title">Some Text</span>
<span class="sao-top-2-type">More Text</span>
<span class="sao-top-2-price">Even More Text</span>
</th>
<th class="sao-top-3">
<span class="sao-top-3-title">Some Text</span>
<span class="sao-top-3-type">More Text</span>
<span class="sao-top-3-price">Even More Text</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th class="sao-feature">Text</th>
<td class="sao-detail">Text</td>
<td class="sao-detail">Text</td>
</tr>
<tr>
<th class="sao-feature">Text</th>
<td class="sao-detail">Text</td>
<td class="sao-detail">Text</td>
</tr>
There seems to be a problem with my table layout. The nth-child pseudo selector is making every other column black instead of alternating rows. How can I fix this issue? Edit: I tried the row span example recommended, but it doesn't use the nth-child selector. I'm unsure of what I'm missing. Can someone provide some insight?