我一直在尝试根据与各个li项目关联的类名称来为li项目设置不同的样式。我想更改所有类的所有偶项的颜色。
ul .first:nth-child(even),
ul .second:nth-child(even),
ul .third:nth-child(even) {
color: red;
}
<ul>
<li class="first">Class First - Item First</li>
<li class="first">Class First - Item Second</li>
<li class="first">Class First - Item Third</li>
<li class="first">Class First - Item Fourth</li>
<li class="first">Class First - Item Fifth</li>
<li class="second">Class Second - Item First</li>
<li class="second">Class Second - Item Second</li>
<li class="second">Class Second - Item Third</li>
<li class="second">Class Second - Item Fourth</li>
<li class="second">Class Second - Item Fifth</li>
<li class="third">Class Third - Item First</li>
<li class="third">Class Third - Item Second</li>
<li class="third">Class Third - Item Third</li>
<li class="third">Class Third - Item Fourth</li>
<li class="third">Class Third - Item Fifth</li>
</ul>