Это мой ДОМ. Мне нужно выбрать средний столбец три раза, пропустить node, повторить:
+-------------------+ <div class="grid">
| +---+ +---+ +---+ | <div class="cell">1</div>
| | 1 | | 2 | | 3 | | <div class="cell">2</div>
| +---+ +---+ +---+ | <div class="cell">3</div>
| +---+ +---+ +---+ | <div class="cell">4</div>
| | 4 | | 5 | | 6 | | <div class="cell">5</div>
| +---+ +---+ +---+ | <div class="cell">6</div>
| +---+ +---+ +---+ | <div class="cell">7</div>
| | 7 | | 8 | | 9 | | <div class="cell">8</div>
| +---+ +---+ +---+ | <div class="cell">9</div>
| +---------------+ |
| | AD UNIT | | <div class="adUnit"></div>
| +---------------+ |
| +---+ +---+ +---+ | <div class="cell">11</div>
| | 11| |12 | |13 | | <div class="cell">12</div>
| +---+ +---+ +---+ | <div class="cell">13</div>
| +---+ +---+ +---+ | <div class="cell">14</div>
| |14 | |15 | |16 | | <div class="cell">15</div>
| +---+ +---+ +---+ | <div class="cell">16</div>
| +---+ +---+ +---+ | <div class="cell">17</div>
| |17 | |18 | |19 | | <div class="cell">18</div>
| +---+ +---+ +---+ | <div class="cell">19</div>
| +---------------+ |
| | AD UNIT | | <div class="adUnit"></div>
| +---------------+ |
| +---+ +---+ +---+ | <div class="cell">21</div>
| |21 | |22 | |23 | | <div class="cell">22</div>
| +---+ +---+ +---+ | <div class="cell">23</div>
| +---+ +---+ +---+ | <div class="cell">24</div>
| |24 | |25 | |...| | <div class="cell">25</div>
| +---------------+ | <!-- ... -->
+-------------------+ </div>
TL;DR
Мне нужно выбрать следующую последовательность [дочерних узлов]:
2, 5, 8,
12, 15, 18,
22, 25, 28,
32, 35, 38, ...
Я достиг этого с тремя отдельными функциями nth-child:
-
.grid .cell:nth-child(10n + 2)
(2, 12, 22, 32,...) -
.grid .cell:nth-child(10n + 5)
(5, 15, 25, 35,...) -
.grid .cell:nth-child(10n + 8)
(8, 18, 28, 38,...)
Вопрос:
Могут ли эти три функции быть переписаны в один?