<div class="test"> one </div>
<div class="test"> two </div>
<div class="test"> three </div>
<div class="test"> four </div>
<div class="test"> five </div>
<div class="test"> six </div>
.test {
background: #ff4040;
color: #fff;
display: block;
font-size: 15px;
}
I need to remove background color from last three divs using css or simple javascript. The conditions are I need to only remove styles from last three divs and its doesn't matter how many divs we are using and it should support in almost every browsers.
A Simple solution.
You can select the last 3div using.
.test:nth-last-child(-n+3) {
/*declarations*/
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With