To fix :last-child not working as expected with CSS, we should make sure the element we’re selecting is the last element.
For instance, we write
<div>
<a></a>
<a>This will be selected</a>
</div>
to add 2 a
elements into the div.
Then we write
div a:last-child {
}
to select the last a
element in the div with div a:last-child
.