Combining two or more CSS selectors with a boolean condition

前端 未结 3 1282
情话喂你
情话喂你 2021-01-05 03:22

Is there a way to combine two or more CSS selectors using a boolean condition - and, or, not?

Consider this

<
3条回答
  •  说谎
    说谎 (楼主)
    2021-01-05 03:48

    These should work:

    && = div.message.error {}
    || = div.message, div.error {}
    

    Don't think you can do "not"

    Edit: Just did a quick test to confirm:

    
        
            
        
        
            
    None
    Error
    Message
    Error Message

    The "message", "error" and "error message" divs all have a green border and only the "error message" div has a red background.

提交回复
热议问题