0

私は次のことをしたい:

.feed > :not(:nth-child(n+5):nth-child(-n+10))

しかし、明らかにそれはcssでは利用できません。これを回避する方法はありますか?

4

2 に答える 2

3

使用できます

.feed > :not(:nth-child(n+5)), .feed > :not(:nth-child(-n+10)) {
    background: red;
}

デモ

説明

これはAND:nth-child(n+5):nth-child(-n+10)を意味するためです。:nth-child(n+5)nth-child(-n+10)

しかし、ド・モルガンの法則によれば、

not(A AND B) = not(A) OR not(B)

次に、それを否定したい場合は、代わりに:not(:nth-child(n+5):nth-child(-n+10))OR 演算子が必要です,

:not(:nth-child(n+5)), :not(:nth-child(-n+10))
于 2013-11-07T23:07:51.157 に答える