我的 HTML 中有一些 div,动态数量的 div
如何仅选择 div 2,5,8,11 ?
我试过了,:nth-child(2n+3)
但不完全是我需要的
这是代码:
<!DOCTYPE html>
<html>
<head>
<style>
.a:nth-child(2n+3) { background:#ff0000; }
</style>
</head>
<body>
<p class="a">The first paragraph.</p>
<p class="a">The second paragraph.</p>
<p class="a">The third paragraph.</p>
<p class="a">The fourth paragraph.</p>
<p class="a">The fifth paragraph.</p>
<p class="a">The sixth paragraph.</p>
<p class="a">The seventh paragraph.</p>
<p class="a">The eight paragraph.</p>
<p class="a">The ninth paragraph.</p>
<p class="a">The seventh paragraph.</p>
<p class="a">The eight paragraph.</p>
<p class="a">The ninth paragraph.</p>
</body>
</html>