gpt4 book ai didi

css - 使用 :not() and styling with nth-of-type odd & even 忽略行

转载 作者:行者123 更新时间:2023-11-28 09:34:10 26 4
gpt4 key购买 nike

<分区>

我想用其他背景设置 li's 的样式。图案应该是红色 > 蓝色 > 红色 > 蓝色等。

问题是我正在使用 :not 选择器来忽略一个列表中的第一行,因此该列表的模式从蓝色 > 红色 > 蓝色开始。我明白为什么会这样,但我想知道是否有可能 :nth-of-type() odd and even 忽略其计算中的行?或者如果没有向我的 html 添加额外标记的解决方法。

http://jsbin.com/kusolecudo/edit?html,css,output

我不想对我的 HTML 应用任何额外的标记,也不想为 :not 列表复制我的 CSS。

li:not(.head):nth-of-type(odd)
{ background: red }

li:not(.head):nth-of-type(even)
{background: blue }


ul {width:40%;display:inline-block;list-style:none}
<ul>
<li class="head">
test
</li>
<li>
test
</li>
<li>
test
</li>
</ul>


<ul>
<li>
test
</li>
<li>
test
</li>
<li>
test
</li>
</ul>

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com