CSS Selector for not a child of element type?

前端 未结 1 1099
粉色の甜心
粉色の甜心 2020-12-05 16:49

I want to style code elements that are not inside a tags.

What is the best approach to accomplish this?

code:not(a code)

1条回答
  •  一生所求
    2020-12-05 17:22

    :not does not support combinator selectors.

    If we're talking about its direct parent:

    :not(a) > code
    

    Otherwise there's no way to do this in CSS. You'll have to override it:

    code {
        /* some styles */
    }
    
    a code {
        /* override previous styles */
    }
    

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