p:nth-child(even)
和p:nth-child(odd)
在几个<p>
之后放置中间s而失去计数
这是我得到的:
p:nth-child(even) {
font-style: italic;
}
<p> text </p>
<p> more text <//p>
<p> and still more text <//p>
<div> stuff </div>
<p> text </p>
<p> more text <//p>
开头很好:斜体,普通字体,斜体,普通字体,普通字体
中间的<div> stuff </div>
重置一切。
? ?
我想你可能想要nth-of-type
的功能,而不是基于你所描述的nth-child
。文章在这里的区别https://css-tricks.com/the-difference-between-nth-child-and-nth-of-type/
您的示例:https://jsfiddle.net/nh16ytq7/