Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] SCSS Change Variable depending on parent class Reply To: SCSS Change Variable depending on parent class

#153454
Alen
Participant

You could use @extend.

$blue-color: blue;
$red-color: red;
$green-color: green;
.base-box{
    display:block;
    width: auto;
    color: $blue-color;
}
.base-box-1{
    @extend .base-box;
    color: $red-color;
}
.base-box-1{
    @extend .base-box;
    color: $green-color;
}

Compiles to:

.base-box, .base-box-1 {
  display: block;
  width: auto;
  color: blue; }

.base-box-1 {
  color: red; }

.base-box-1 {
  color: green; }