Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inherit attributes from another object in css

Tags:

css

I have a class in my css called .btn:

.btn {
    //stuff here
}

and I am going to create another class, lets say .btn2. I want to be able to inherit the characteristics from .btn into btn2, as I only want to change the color of button 2. Is there a way in CSS for this? Or should I just copy and paste the original stuff into the new class?

like image 665
rshah Avatar asked Nov 19 '25 13:11

rshah


1 Answers

I'd suggest:

/* comma-separated selectors: */
.btn,
.btn2 {
    /* shared properties */
}

.btn2 {
    /* properties unique to btn2 */
}

JS Fiddle demo.

like image 145
David Thomas Avatar answered Nov 21 '25 02:11

David Thomas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!