I have this in my SCSS file:
.class-a{ display: inline-block; //some other properties &:hover{ color: darken(#FFFFFF, 10%); } } .class-b{ //Inherite class-a here //some properties }
In class-b, I would like to inherite all properties and nested declarations of class-a
. How is this done? I tried using @include class-a
, but that just throws an error when compiling.
The @extend directive lets you share a set of CSS properties from one selector to another. The @extend directive is useful if you have almost identically styled elements that only differ in some small details.
You can use any CSS selector while nesting with spaces, you can use id selectors with #id-name, tag selectors like h1, pseudo-classes, etc.
Looks like @mixin
and @include
are not needed for a simple case like this.
One can just do:
.myclass { font-weight: bold; font-size: 90px; } .myotherclass { @extend .myclass; color: #000000; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With