CSS Selector “(A or B) and C”?

前端 未结 4 1251
时光取名叫无心
时光取名叫无心 2020-11-27 14:24

This should be simple, but I\'m having trouble finding the search terms for it.
Let\'s say I have this:

Foo
4条回答
  •  日久生厌
    2020-11-27 14:46

    If you have this:

    Foo
    Bar
    Baz

    And you only want to select the elements which have .x and (.a or .b), you could write:

    .x:not(.c) { ... }
    

    but that's convenient only when you have three "sub-classes" and you want to select two of them.

    Selecting only one sub-class (for instance .a): .a.x

    Selecting two sub-classes (for instance .a and .b): .x:not(.c)

    Selecting all three sub-classes: .x

提交回复
热议问题