I
I
Igorek982021-05-07 16:12:53
Sass
Igorek98, 2021-05-07 16:12:53

How to set a set of properties through a variable in sass?

Is it possible to set a set of properties to a variable in sass and pass them to it?
For example, I do not want to write in every 2nd block

position:relative;
width:100%;
height:auto;

Can I put it in a more abbreviated way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2021-05-07
@Igorek98

Or use mixins

@mixin mix1 {
  position:relative;
  width:100%;
  height:auto;
}

.selector {
  @include mix1;
}

Or extends. From placeholders
%set1 {
  position:relative;
  width:100%;
  height:auto;
}

.selector {
  @extend %set1;
}

or from classes
.someclass {
  position:relative;
  width:100%;
  height:auto;
}

.selector {
  @extend .someclass;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question