使用nth(child,of-type)仅选择中间

时间:2016-08-06 10:26:11

标签: html css css3 css-selectors match

我正在尝试使用nth-child或nth-of-type或者各种类型的“nth”来匹配我桌子中的一些元素但是我坚持将目标中的元素从下面的图片中选择为绿色,可以有人给我一个想法如何做到这一点,我不想重复一个间隔只是想选择那一节。我不想为此使用javascript或jQuery。

enter image description here

small fide example:

.row:nth-child(n+4) .cell:nth-child(n+4) {
    background: green;
    color: red;
}

1 个答案:

答案 0 :(得分:1)

这是我的问题的答案,我已经解决了自己!

.row:nth-child(n+4):nth-child(-n+6) .cell:nth-child(n+4):nth-child(-n+6){
    background:red;
}