F21 F21 - 3 months ago 7
Sass (Sass) Question

Including another class in SCSS

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.

F21 F21
Answer

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;
}
Comments