I am trying to find last-child on the basic of class and wants to apply some styling but using :last-child selector its not as per expectation. I have a limitation I don't want to use java script and due the elements length is not fixed I can not use nth selector.
Used HTML Markup
<ul>
<li class="a">First</li>
<li class="a">Second</li>
<li class="a">Third</li>
<li class="b">First</li>
<li class="b">Second</li>
<li class="b">Third</li>
<li class="c">First</li>
<li class="c">Second</li>
<li class="c">Third</li>
</ul>
Used Css
.a{
color:red;
}
.b{
color:blue;
}
.c{
color:green;
}
.a:last-child{
color:green;
}
.b:last-child{
color:red;
}
.c:last-child{
color:blue;
}
Any help to how to approach this problem.