I have following list:
<ul>
<li class="parent">1.</li>
<li class="child">1. first</li>
<li class="child">1. second</li>
<li class="child">1. third</li>
<li class="parent">2.</li>
<li class="child">2. first</li>
<li class="child">2. second</li>
<li class="child">2. third</li>
<li class="child">2. fourth</li>
<li class="child">2. fifth</li>
<li class="parent">3.</li>
<li class="child">3. first</li>
<li class="child">3. second</li>
<li class="child">3. third</li>
<li class="child">3. fourth</li>
<li class="parent">4.</li>
<li class="child">4. first</li>
<li class="child">4. second</li>
<li class="child">4. third</li>
</ul>
I want to set specified background for first
and last elements. While I have no problem with the first
:
.parent + .child {
background-color: whitesmoke;
}
then I do not know what to do with the lasts.
Simply: I want to match .child
before .parent
.