是否可以选择CSS中的其他三个组? [英] Is it possible to select every other group of three in CSS?
本文介绍了是否可以选择CSS中的其他三个组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有可能在CSS中选择三个其他组吗?如果是的话;如何?
Is it possible to select every other group of three in CSS? And if it is; how?
因此,在下面的示例中,将样式应用于4-6和10-12 li
/ p>
So in the sample below apply style to the 4-6 and 10-12 li
s.
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
<li>11</li>
<li>12</li>
</ul>
我知道[pure] JavaScript和jQuery可以做到这一点,但我正在寻找一个纯CSS解决方案if
I know [pure] JavaScript and jQuery can do this but I am looking for a pure CSS solution if it exists.
推荐答案
您正在寻找nth-child:
You're looking for nth-child:
ul li:nth-child(6n+4),ul li:nth-child(6n+5),ul li:nth-child(6n+6) {
background:red;
}
http://jsfiddle.net/bhlaird/utEP4/1/
这篇关于是否可以选择CSS中的其他三个组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文