I've got a dom structure which is generated by a JS framework and may looks like this:
span:nth-child(odd) { background-color: lightblue; }
span {
display: block;
}
<div id="parent">
<div class="child">
<span>Some text to color in alternate colors with the previous span no matter if it's the same parent or not</span>
<span>Some text to color in alternate colors with the previous span no matter if it's the same parent or not</span>
</div>
<div class="child">
<span>Some text to color in alternate colors with the previous span no matter if it's the same parent or not</span>
</div>
<div class="child">
<span>Some text to color in alternate colors with the previous span no matter if it's the same parent or not</span>
<span>Some text to color in alternate colors with the previous span no matter if it's the same parent or not</span>
<span>Some text to color in alternate colors with the previous span no matter if it's the same parent or not</span>
</div>
<div class="child">
<span>Some text to color in alternate colors with the previous span no matter if it's the same parent or not</span>
<span>Some text to color in alternate colors with the previous span no matter if it's the same parent or not</span>
<span>Some text to color in alternate colors with the previous span no matter if it's the same parent or not</span>
<span>Some text to color in alternate colors with the previous span no matter if it's the same parent or not</span>
<span>Some text to color in alternate colors with the previous span no matter if it's the same parent or not</span>
<span>Some text to color in alternate colors with the previous span no matter if it's the same parent or not</span>
</div>
<div class="child">
<span>Some text to color in alternate colors</span>
</div>
</div>
I'm trying to color the span alternatively no matter if the parent is the same or not. I gave it a try with pseudo selectors and this question CSS div alternating colour, with no luck. Is this achievable with CSS only or should I dig into a JS framework solution based?