Inherit CSS class

后端 未结 9 1230
既然无缘
既然无缘 2020-12-09 07:45

I have one base .base{} in my CSS file with couple properties. I want to change only color and other properties to stay same. How to inherit this base class inother classe

9条回答
  •  无人及你
    2020-12-09 07:52

    Something like this:

    .base {
        width:100px;
    }
    
    div.child {
        background-color:red;
        color:blue;
    }
    
    .child {
        background-color:yellow;
    }
    
    
    hello world

    The background here will be red, as the css selector is more specific, as we've said it must belong to a div element too!

    see it in action here: jsFiddle

提交回复
热议问题