Tr: the latter doesn't work

Probably some silly reason why it doesn't work, but I tend to mess up the css a bit. So maybe this applies to others as well. CSS:

.bet_history table {
    width: 1000px;
    display: block;
    border-collapse: collapse;
}
.bet_history td {
    padding: 0;
    font-size: 13px;
    text-align: center;
    padding-top: 1px;
    padding-bottom: 1px;
    background: #0361ba;
    color: #BDD6CE;
}
.bet_history tr {
    border-bottom: 1px solid black;
}
.bet_history tr:last-child {
    background: red;
}
.bet_history td.bet_history2 {
    color: #F0F0F0;
    width: 650px;
}
.bet_history td.bet_history1 {
    background-color: #0354a1;
    color: white;
    width: 100px;
    cursor: pointer;
    -o-transition:.5s;
    -ms-transition:.5s;
    -moz-transition:.5s;
    -webkit-transition:.5s;
    transition:.5s;
}
.bet_history td.bet_history1:hover {
    color: #3399FF;
}

      

And here's the HTML: Edited!

<div id="main">

admin1<br />


<table class="bet_history">

<tr><td style="width: 250px;">Bet ID: #6. 09-22-2014 16:08</td><td class="bet_history1">Match ID #6</td><td class="bet_history2"><span style="color: #00FFFF;">10000</span> minerals on Cure(2.00). Your bet returned <span style="color: #00FFFF;">0</span> minerals. Better luck next time!</td></tr><tr><td style="width: 250px;">Bet ID: #5. 09-22-2014 16:06</td><td class="bet_history1">Match ID #4</td><td class="bet_history2"><span style="color: #00FFFF;">2222</span> minerals on Snute(2.30). Your bet returned <span style="color: #00FFFF;">5110.6</span> minerals. Congratulations!</td></tr><tr><td style="width: 250px;">Bet ID: #4. 09-22-2014 15:58</td><td class="bet_history1">Match ID #4</td><td class="bet_history2"><span style="color: #00FFFF;">2222</span> minerals on Snute(2.30). Your bet returned <span style="color: #00FFFF;">5110.6</span> minerals. Congratulations!</td></tr><tr><td style="width: 250px;">Bet ID: #3. 09-22-2014 15:25</td><td class="bet_history1">Match ID #5</td><td class="bet_history2"><span style="color: #00FFFF;">600</span> minerals on Lars(4.00). Your bet returned <span style="color: #00FFFF;">2400</span> minerals. Congratulations!</td></tr><tr><td style="width: 250px;">Bet ID: #2. 09-22-2014 12:03</td><td class="bet_history1">Match ID #3</td><td class="bet_history2"><span style="color: #00FFFF;">64</span> minerals on naniwa(9.00). Your bet returned <span style="color: #00FFFF;">576</span> minerals. Congratulations!</td></tr><tr><td style="width: 250px;">Bet ID: #1. 09-20-2014 16:00</td><td class="bet_history1">Match ID #1</td><td class="bet_history2"><span style="color: #00FFFF;">20</span> minerals on Snute(2.20). Your bet returned <span style="color: #00FFFF;">44</span> minerals. Congratulations!</td></tr>
</table>
</div>

      

Why doesn't the last child apply to the last tr? It will be if I set it to td. I'm sure this is some kind of stupid thing I did in css. This is not a finished product. I'm just wondering why the last kid isn't working.

+3


source to share


1 answer


As @Vucko mentioned in the comments, the style is applied tr:last-child

, however the td on that line overrides that style.

If you want all the tds on the last line to be red, edit your class:



.bet_history tr:last-child td {
    background: red;
}

      

FIDDLE

+4


source







All Articles