T
T
Test Test2015-02-25 16:53:28
css
Test Test, 2015-02-25 16:53:28

How to make class name inheritance in SCSS?

Good evening! Faced such a problem.
I have this css file:

.menu { ... }
.menu .menu-list { ... }
.menu .menu-list .menu-list-item { ... }
.menu .menu-list .menu-list-item:hover { ... }

Trying to port it to SCSS
.menu {
  ...
  & &-list {
      ....
      & &-item {
             ....
            &:hover {
               ....
            }
       }
   }
}

But it doesn't work out the way you want it to.
.menu { ... }
.menu .menu-list { ... } 
.menu .menu-list .menu .menu-list-item { ... }

Do not know how to solve the problem?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Evgeny Komarov, 2015-02-25
@maNULL

you need to translate someone else's code into scss. Or are there any alternatives?

well , google ... there are a lot of services. not everyone is perfect, you will have to tweak the handles in places

A
Andrey B., 2015-02-25
@andykov

.menu {
  ...
  .menu-list {
    ...
    .menu-list-item {
      ...
      &:hover {
        ...
      }
    }
  }
}

At the exit:
.menu{...}
.menu .menu-list{...}
.menu .menu-list .menu-list-item{...}
.menu .menu-list .menu-list-item:hover{...}

N
Nikolai Shabalin, 2015-02-25
@nikolayshabalin

It turns out some kind of tin

.menu {
  color: red;
  .menu {
    &-list {
      color: green;
      .menu-list {
        &-item {
          color: blacl;
          &:hover {
            color: orange;
          }
        } 
      }
    } 
  }
}

Link

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question