S
S
Serj-One2021-05-06 14:50:39
Sass
Serj-One, 2021-05-06 14:50:39

How to use a mixin or SCSS function to set a property to an element if it is inside an element with a certain class?

Rough idea of ​​what I want to get

@mixin alt{
   // Что написать здесь, чтоб получить результат, описанный далее ?
}

.test{
  background: red;
  @include alt{
    background: green;
  }
}

.test{background: red}
.alt .test{background: green}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2021-05-06
@Serj-One

https://www.sassmeister.com/gist/02a5a21b685de4e02...
Anton Litvinenko

@mixin alt {
    .alt & {
      @content;
    }
}

.test{
  background: red;
  @include alt{
    background: green;
  }
}

It?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question