How can I select all elements except those inside divs with particular classes

前端 未结 1 793
清酒与你
清酒与你 2021-01-16 06:39

I\'d like to find a way to select all the makes of cars except those that are inside a div with the class discontinued or scrapped. Here\'s my mark

1条回答
  •  清歌不尽
    2021-01-16 07:11

    Unfortunately CSS selectors cannot traverse up parent elements, so if you are just trying to style them differently you may want to reverse your thought process and select ones that are .discontinued or .scrapped and apply overriding styles:

    .model {
      padding-left: 10px;
    }
    
    .make {
      color: green;
    }
    
    .scrapped .make,
    .discontinued .make {
      color: red;
    }
    NISSAN
    MICRA
    FORD
    MONDEO
    SEAT
    IBIZA
    SEAT
    IBIZA
    HONDA
    INTEGRA
    PEUGEOT
    206
    TOYOTA
    COROLLA

    0 讨论(0)
提交回复
热议问题