Reputation: 766
Can I create "class inheritance" in CSS? Something like:
.squareButton {width:20px; height:20px; margin:1px solid;}
.squareRedButton {.squareButton; background:red;}
Upvotes: 0
Views: 70
Reputation: 4246
Yes you can, just apply the desired CSS to both the class you need :
.squareButton, .squareRedButton {
width : 20px;
height : 20px;
margin : 1px solid;
}
.squareRedButton {
background : red;
}
Note
You can pass through HTML to use several classes to perform an inheritance like following :
CSS
.squareButton {
width : 20px;
height : 20px;
margin : 1px solid;
}
.squareRedButton {
background:red;
}
HTML
<button class="squareButton squareRedButton">MyButton</button>
Upvotes: 2
Reputation: 9508
.squareButton{
width : 20px;
height : 20px;
margin : 1px solid;
}
.bg-red {
background : red;
}
<div class="squareButton bg-red">
This is the short code way of doing.
Upvotes: 0