嗯,我想弄清楚我的第n个孩子选择器的公式。css nth孩子公式生成器
我想知道是否有像公式生成器。
输入我想要定位的元素的数量。 而出来的公式
我想找到以下数字的公式:1,2,4,5,7,8,10,11,等。
因此,跳过每第三个元素。
编辑
我不得不跳过前两个,所以我
li:nth-child(3n+4), li:nth-child(3n+5)
嗯,我想弄清楚我的第n个孩子选择器的公式。css nth孩子公式生成器
我想知道是否有像公式生成器。
输入我想要定位的元素的数量。 而出来的公式
我想找到以下数字的公式:1,2,4,5,7,8,10,11,等。
因此,跳过每第三个元素。
编辑
我不得不跳过前两个,所以我
li:nth-child(3n+4), li:nth-child(3n+5)
使用:nth-child(3n + 1)
和:nth-child(3n + 2)
去了。
ul li:nth-child(3n + 1), ul li:nth-child(3n + 2) {
color: red;
}
<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>
<li>13</li>
<li>14</li>
<li>15</li>
</ul>
一些数学:
{1,2,4,5,7,8,10,11,...}
= {1,4,7,10,...} ∪ {2,5,8,11,...}
= {3n+1 : n ∈ ℕ*} ∪ {3n+2 : n ∈ ℕ*}
凡ℕ* = ℕ ∪ {0}
因此,您可以使用
:nth-child(3n+1), :nth-child(3n+2) {
/* Code */
}
你能指导我到哪里可以阅读更多关于这种类型的数学。 – PrivatMamtora 2014-12-07 22:19:11
@PrivatMamtora在维基百科,试试[设置(数学)](http://en.wikipedia.org/wiki/Set_%28mathematics%29)。 – Oriol 2014-12-07 22:22:25
你的一个公式应该是3n + 2 – PrivatMamtora 2014-12-07 23:23:02
那么,寻找反向,输入我想要的并获得公式。找到类似http://nth-calculator.com/的东西,但它没有找到一个公式,但是为每个数字提供了一个不同的公式。 – PrivatMamtora 2014-12-07 22:10:16