Can I write a CSS selector selecting elements NOT having a certain class or attribute?

前端 未结 10 610
不知归路
不知归路 2020-11-22 10:47

I would like to write a CSS selector rule that selects all elements that don\'t have a certain class. For example, given the following HTML:



        
10条回答
  •  無奈伤痛
    2020-11-22 11:36

    If you want a specific class menu to have a specific CSS if missing class logged-in:

    body:not(.logged-in) .menu  {
        display: none
    }
    

提交回复
热议问题