S
S
Sergey Shilov2018-09-20 13:56:18
Sass
Sergey Shilov, 2018-09-20 13:56:18

How to set a variable directly to several classes in scss?

Hey! I need to put a direct block of properties into one variable:

#front-hello {
        padding: 20vh 0 1vh;
        .front-hello-slider {
            position: relative;
            top: -1.5vw;
            .slider-vertical-item {
                margin-bottom: 2.3vw;
            }
            img {
                width: 53px;
            }
        }   
    }

and I need to directly clone this design to several different places, can I somehow declare this whole thing? mixins did not understand how

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
abberati, 2018-09-20
@abberati

learn to ask questions. based on the comment under the answer Sergey : maybe like this?

@mixin my-mixin($classname, $anotherClassname) {
  padding: 20vh 0 1vh;
  #{$classname} {
    position: relative;
    top: -1.5vw;
    #{$anotherClassname} {
      margin-bottom: 2.3vw;
    }
    img {
      width: 53px;
    }
  }
}

#front-hello {
 @include my-mixin('.front-hello-slider','.slider-vertical-item');
}

#back-hello {
 @include my-mixin('.back-hello-slider','.slider-vertical-item');
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question