Cancel a CSS declaration

后端 未结 8 999
礼貌的吻别
礼貌的吻别 2021-02-07 08:47

Is it possible to have a CSS rule which basically \"undoes\" a prior rule?

An example:

some text more text ot
8条回答
  •  孤城傲影
    2021-02-07 09:19

    My CSS is a bit rusty, but this should work:

    blockquote {
        color: red;
    }
    
    blockquote em {
        color: inherit;
    }
    

    You are setting blockquotes to red, but all 's that are contained in a blockquote should inherit... hmmm, should they inherit from the surrounding text, or from the blockquote?

    If the above does not work as you want, then there is no way to do it with the current markup, I think. You would have to work with additional markup, or set the colour explicitltly, e.g.

    blockquote em {
            color: Purple;
    } 
    

提交回复
热议问题