N
N
nikmil2021-12-10 16:58:22
css
nikmil, 2021-12-10 16:58:22

How to correctly write scss according to my template?

Hello, I've run into a problem.
I have a theme page, here is an example html

<div class='theme-1'>
  <div class='main'>
    <div class='main-child >
      <div class='main-child -img></div>
     </div>
  </div>
</div>


.theme 1 {
  .main {
    &-child {
       &:hover &-img {}  <---- 
    }
 }
}


The problem is that in scss
everything is inherited well until one moment where hover on child to change img

61b35e3723106662259431.jpeg
<- it inherits like

this
<element class="theme-1>
<element class="main-child" :hover>
  …
    <element class="main-child-img">

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2021-12-10
@nikmil

.main {
  $this: &;

  .theme_1 & {
    #{$this}-child:hover #{$this}-img {
    }
 }
}

.main {
  $this: &;

  @at-root {
    .theme_1 {
      #{$this}-child:hover #{$this}-img {
      }
    }
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question